@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
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
//
|
|
8
8
|
// The fold's rules, in order: a print needs a BUY or SELL series side, a
|
|
9
9
|
// finite positive amount, a finite price and a wire timestamp; a print below
|
|
10
|
-
// the acquisition's
|
|
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
|
|
11
13
|
// large-print table never holds (`tradesBelowLargeFloor`: a dollar-quoted
|
|
12
14
|
// market's print under the notional floor, a CME Group print under its
|
|
13
15
|
// product root's contracts floor); the print lands in the chart bar
|
|
@@ -16,11 +18,23 @@
|
|
|
16
18
|
// LIVE_MAX_CELLS_PER_BAR prints (the oldest are dropped and the caller is told
|
|
17
19
|
// through `onCapped`); the fold never mutates the rows or the cells it is
|
|
18
20
|
// handed (the touched row is a new array in a new container).
|
|
21
|
+
//
|
|
22
|
+
// The floor is an ORDER's where the plane judges it per order: one aggressor
|
|
23
|
+
// order on a CME Group venue fills as many small fills on one exchange stamp
|
|
24
|
+
// and side, which the package (Big Trades' "Combine fills") and the template
|
|
25
|
+
// add back into one trade. A floor applied to each fill before that drops the
|
|
26
|
+
// fills of a big order one by one (a 147-contract NQZ6 buy of 45 fills drew 34
|
|
27
|
+
// at a floor of 10). So where the per-order switch holds (wrun-tape-per-order
|
|
28
|
+
// .util `wrunTapePerOrder`, on the venues `tradesFloorPerOrder` names) the
|
|
29
|
+
// history read asks the gateway's per-order floor and keeps every fill it
|
|
30
|
+
// answers, and the tape's live prints, judged per order by the order gate
|
|
31
|
+
// before the queues (live-trades-order-gate.util), fold with no floor of
|
|
32
|
+
// their own (`TradesTapeFloor.perOrder`).
|
|
19
33
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
20
34
|
import { barEndMs, barStartMs } from '../../utility/chart/calendar-interval.util.js';
|
|
21
35
|
import { cmeSessionBarEndMs, cmeSessionBarOpenMs, cmeSessionBucketMs, isCmeSessionLatticeExchange, isCmeSessionLatticeIntervalMs, } from '../../utility/chart/cme-session-bucket.util.js';
|
|
22
36
|
import { findMonday } from '../../workers/utils/time.worker.util.js';
|
|
23
|
-
import { liveOptionPrintPremium } from '../../utility/options/option-trade-units.util.js';
|
|
37
|
+
import { liveOptionPrintPremium, liveOptionPrintUsdPremium, } from '../../utility/options/option-trade-units.util.js';
|
|
24
38
|
export const LIVE_MAX_CELLS_PER_BAR = 20_000;
|
|
25
39
|
/** The most prints one history ask reads (the history worker's cap, mirroring the historical service's
|
|
26
40
|
* HIST_TRADES_MAX_CELLS): past it the ask fails loudly instead of truncating the tape, and the wrun tape's refusal
|
|
@@ -45,7 +59,9 @@ const TRADES_LARGE_BAR_LIMIT_MARGIN_SEC = 600;
|
|
|
45
59
|
* is copied into the table when its quote amount reaches it. */
|
|
46
60
|
export const TRADES_LARGE_MIN_QUOTE_AMOUNT = 10_000;
|
|
47
61
|
/** The quote assets whose quote amount is dollars (the gateway writer's `peggedUSDQuotes`): only the
|
|
48
|
-
* prints of a market quoted in one of these are copied into trade_large, every other quote never.
|
|
62
|
+
* prints of a market quoted in one of these are copied into trade_large, every other quote never. The
|
|
63
|
+
* dollar rule of a market's value (wrun-chart-market-facts.util `wrunMarketDollarUnit`) reads the same
|
|
64
|
+
* list (`isTradesDollarQuoteAsset`). */
|
|
49
65
|
const TRADES_LARGE_USD_QUOTES = new Set([
|
|
50
66
|
'USD',
|
|
51
67
|
'USDT',
|
|
@@ -114,6 +130,15 @@ export const TRADES_LARGE_CME_CONTRACT_FLOORS = {
|
|
|
114
130
|
export const TRADES_MAX_HISTORY_SEC = 2 * 3600;
|
|
115
131
|
/** A CME Group contract code: the product root, a delivery month letter, one or two year digits. */
|
|
116
132
|
const CME_CONTRACT_CODE = /^([A-Z0-9]+?)[FGHJKMNQUVXZ]\d{1,2}$/;
|
|
133
|
+
/** A live point's trade, whichever case carries it: the raw TRADE channel's `trade` or the large-print channel's
|
|
134
|
+
* `tradeLarge` (the history adapter reads the two the same way). Every reader of a live print's amount reads it here,
|
|
135
|
+
* so a floor never reads one case while the fold reads the other. */
|
|
136
|
+
export function liveTradeOfPoint(point) {
|
|
137
|
+
if (!point || typeof point !== 'object')
|
|
138
|
+
return undefined;
|
|
139
|
+
const { trade, tradeLarge } = point;
|
|
140
|
+
return trade ?? tradeLarge;
|
|
141
|
+
}
|
|
117
142
|
/**
|
|
118
143
|
* The chart bar a print at `tsMs` lands in, keyed the way the chart's candles of that market are:
|
|
119
144
|
* the CME Group session lattice at 4h, 1d and 1w on a CME venue (the gateway's
|
|
@@ -193,14 +218,14 @@ export function tradesServedStartMs(nowMs, historySec, intervalMs, options = {})
|
|
|
193
218
|
? Number.NEGATIVE_INFINITY
|
|
194
219
|
: tradesBarLimitStartMs(nowMs, options.barLimitSec, intervalMs, options.exchange));
|
|
195
220
|
}
|
|
196
|
-
/** One raw TRADE point read the way the fold reads it:
|
|
197
|
-
* signed side and envelope exchange; null for a point the
|
|
198
|
-
* or non-finite size, a bad price or stamp). */
|
|
221
|
+
/** One raw TRADE point (or a TRADE_LARGE one, its `tradeLarge` case) read the way the fold reads it:
|
|
222
|
+
* the print's stamp in ms, its price, size, signed side and envelope exchange; null for a point the
|
|
223
|
+
* fold rejects (no side, a non-positive or non-finite size, a bad price or stamp). */
|
|
199
224
|
export function readLiveTradePrint(newPoint) {
|
|
200
225
|
if (!newPoint || typeof newPoint !== 'object')
|
|
201
226
|
return null;
|
|
202
227
|
const point = newPoint;
|
|
203
|
-
const trade = point
|
|
228
|
+
const trade = liveTradeOfPoint(point);
|
|
204
229
|
const side = point.series?.side === 'BUY' ? 1 : point.series?.side === 'SELL' ? -1 : 0;
|
|
205
230
|
const size = Number(trade?.amount);
|
|
206
231
|
const price = Number(trade?.price);
|
|
@@ -235,6 +260,55 @@ export function tradesLargeQuotedInDollars(normalizedSymbol) {
|
|
|
235
260
|
const quote = normalizedSymbol.split('-')[1];
|
|
236
261
|
return quote !== undefined && TRADES_LARGE_USD_QUOTES.has(quote);
|
|
237
262
|
}
|
|
263
|
+
/** Whether a quote asset's amounts are US dollars: USD or a dollar stablecoin (the gateway writer's
|
|
264
|
+
* `peggedUSDQuotes`, the list the large-print table copies by). */
|
|
265
|
+
export function isTradesDollarQuoteAsset(asset) {
|
|
266
|
+
return typeof asset === 'string' && TRADES_LARGE_USD_QUOTES.has(asset.trim().toUpperCase());
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 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
|
|
270
|
+
* floor rule the wrun intake's enqueue, its fold and the K_TRADES control's fold share.
|
|
271
|
+
*
|
|
272
|
+
* - A dollar floor (`minValue` finite and above zero, C-DOLLAR): the print's dollar value, and the print folds only
|
|
273
|
+
* when it reaches the floor. On an option book (`optionUnits`) its USD premium by the registry units
|
|
274
|
+
* (`liveOptionPrintUsdPremium`: a coin-premium book has none); on every other market price x size x `valuePerUnit`.
|
|
275
|
+
* The size is the live-feed COIN arm's: live-feed already applied each instrument's contract multiplier and its
|
|
276
|
+
* inverse flag (coins on a crypto contract or inverse venue), and a CME Group contract stays one contract, whose
|
|
277
|
+
* point value `valuePerUnit` carries. A print that cannot be valued (no `valuePerUnit`, units that cannot say) is
|
|
278
|
+
* null: it never folds, whatever its size.
|
|
279
|
+
* - Otherwise the raw size, below a finite positive `minSize` null.
|
|
280
|
+
* - On a tape whose prints arrive judged per order (`floor.perOrder`), no floor: the dollar value (above zero), or the
|
|
281
|
+
* raw size, whatever the floor (the fills below it belong to an order that reached it).
|
|
282
|
+
*/
|
|
283
|
+
export function tradesTapeCellSize(print, floor) {
|
|
284
|
+
const perOrder = floor.perOrder === true;
|
|
285
|
+
if (tradesTapeFloorIsDollars(floor)) {
|
|
286
|
+
const minValue = Number(floor.minValue);
|
|
287
|
+
let value;
|
|
288
|
+
if (floor.optionUnits) {
|
|
289
|
+
value = liveOptionPrintUsdPremium(print.price, print.size, floor.optionUnits);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const unit = Number(floor.valuePerUnit);
|
|
293
|
+
value = Number.isFinite(unit) && unit > 0 ? print.price * print.size * unit : null;
|
|
294
|
+
}
|
|
295
|
+
return value !== null && Number.isFinite(value) && value > 0 && (perOrder || value >= minValue) ? value : null;
|
|
296
|
+
}
|
|
297
|
+
if (perOrder)
|
|
298
|
+
return print.size;
|
|
299
|
+
const minSize = Number(floor.minSize);
|
|
300
|
+
return Number.isFinite(minSize) && minSize > 0 && print.size < minSize ? null : print.size;
|
|
301
|
+
}
|
|
302
|
+
/** Whether a tape floor can value a live print at all: a raw floor always can; a dollar floor needs the market's
|
|
303
|
+
* `valuePerUnit` or an option book's units. The live intake records a dollar tape that cannot, by name. */
|
|
304
|
+
export function tradesTapeFloorValuesPrints(floor) {
|
|
305
|
+
if (!tradesTapeFloorIsDollars(floor))
|
|
306
|
+
return true;
|
|
307
|
+
if (floor.optionUnits)
|
|
308
|
+
return true;
|
|
309
|
+
const unit = Number(floor.valuePerUnit);
|
|
310
|
+
return Number.isFinite(unit) && unit > 0;
|
|
311
|
+
}
|
|
238
312
|
/** A live print's notional: its quote amount when the frame carries one, else price x size. On an option
|
|
239
313
|
* book (`optionUnits`) the premium in the book's own currency by the resolver's live-print rule
|
|
240
314
|
* (option-trade-units.util `liveOptionPrintPremium`): a live print's size arrives in coin, live-feed having
|
|
@@ -279,29 +353,60 @@ export function tradesLargeFloorOfMarket(market) {
|
|
|
279
353
|
? { kind: 'notional', min: TRADES_LARGE_MIN_QUOTE_AMOUNT }
|
|
280
354
|
: null;
|
|
281
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Whether the gateway floors a tape read on `exchange` per aggressor ORDER (tsdb-gateway `minAmountPerOrder`, on the
|
|
358
|
+
* TRADE and TRADE_LARGE reads): it sums the fills that share an order (the timestamp, exchange, category, coin, symbol,
|
|
359
|
+
* normalized symbol and side), keeps each order whose total reaches the read's floor (`minAmount`, or `minQuoteAmount`
|
|
360
|
+
* on a dollar tape) and answers EVERY fill of it, the fills below the floor included, rows and columns unchanged. The
|
|
361
|
+
* CME Group venues (the session lattice venues, the gateway's `isCMEGroupExchange`) honor it: one aggressor order there
|
|
362
|
+
* fills as many small fills on one exchange timestamp, and a floor of 10 judged per fill kept 2 of the 45 fills of a
|
|
363
|
+
* 147-contract NQZ6 buy (2026-10-23 14:31:54Z). Every other venue keeps the floor per fill and its read never names the
|
|
364
|
+
* field (a v2-only field moves a read off /v3). The per-order switch (wrun-tape-per-order.util `wrunTapePerOrder`) can
|
|
365
|
+
* hold on these venues alone, and the history worker checks this rule beside the ask's `perOrder` (k-trades.worker).
|
|
366
|
+
*/
|
|
367
|
+
export function tradesFloorPerOrder(exchange) {
|
|
368
|
+
return isCmeSessionLatticeExchange(exchange);
|
|
369
|
+
}
|
|
370
|
+
/** Whether a tape floor is a dollar floor (C-DOLLAR's `minValue`, finite and above zero). */
|
|
371
|
+
export function tradesTapeFloorIsDollars(floor) {
|
|
372
|
+
const minValue = Number(floor.minValue);
|
|
373
|
+
return Number.isFinite(minValue) && minValue > 0;
|
|
374
|
+
}
|
|
282
375
|
/** The tape lane an acquisition rides on a market: the large lane (the table's retention, the
|
|
283
376
|
* gateway's bar limit, the declared history) when it asks `large` and the large-print table holds
|
|
284
377
|
* the market, else the raw tape (a two-hour seed inside the raw table's retention). On a CME Group
|
|
285
378
|
* venue a product root the writer lists no floor for is never copied, so a large acquisition on it
|
|
286
379
|
* reads the raw tape in place of an empty table and its live prints fold unfloored, the same rows
|
|
287
|
-
* either way, until the server lists the root. A
|
|
288
|
-
*
|
|
289
|
-
|
|
380
|
+
* either way, until the server lists the root. A dollar floor (`floor.minValue`) on that raw tape
|
|
381
|
+
* reads no history at all (`historyCapSec` 0, the live edge): the raw tape's quote amounts are priced
|
|
382
|
+
* by no writer rule (a backfill gap is NULL), so its rows are no proven dollars. A market quoted
|
|
383
|
+
* outside dollars keeps the table (the control cannot tell its quote: the table answers it empty, by
|
|
384
|
+
* its own rule). The ONE rule of a tape's served history: the request builder, the reconcile's served
|
|
385
|
+
* start and the queue loss's repair all read it with the acquisition's floor. */
|
|
386
|
+
export function tradesLaneLimits(large, market = {}, floor = {}) {
|
|
290
387
|
const readsLargeTable = large && (!isCmeSessionLatticeExchange(market.exchange) || tradesLargeFloorOfMarket(market) !== null);
|
|
291
|
-
|
|
292
|
-
|
|
388
|
+
if (readsLargeTable) {
|
|
389
|
+
return {
|
|
293
390
|
readsLargeTable,
|
|
294
391
|
historyCapSec: TRADES_LARGE_RETENTION_SEC,
|
|
295
392
|
retentionSec: TRADES_LARGE_RETENTION_SEC,
|
|
296
393
|
barLimitSec: TRADES_LARGE_BAR_LIMIT_SEC,
|
|
297
|
-
}
|
|
298
|
-
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
readsLargeTable,
|
|
398
|
+
historyCapSec: tradesTapeFloorIsDollars(floor) ? 0 : TRADES_MAX_HISTORY_SEC,
|
|
399
|
+
retentionSec: TRADES_RETENTION_SEC,
|
|
400
|
+
};
|
|
299
401
|
}
|
|
300
402
|
/** Whether a history re-ask on a large acquisition answers a market's prints (the tape reconcile
|
|
301
403
|
* restoring what the queue cap dropped): the table on a market it holds, the raw tape on a CME
|
|
302
|
-
* Group root it skips
|
|
303
|
-
*
|
|
304
|
-
|
|
404
|
+
* Group root it skips under a size floor; never a lane that serves no history under the floor
|
|
405
|
+
* (`tradesLaneLimits`: a dollar floor on the raw tape), never a market quoted outside dollars. A
|
|
406
|
+
* market naming no normalized symbol is assumed held. */
|
|
407
|
+
export function tradesLargeHistoryAnswers(market, floor = {}) {
|
|
408
|
+
if (!(tradesLaneLimits(true, market, floor).historyCapSec > 0))
|
|
409
|
+
return false;
|
|
305
410
|
if (isCmeSessionLatticeExchange(market.exchange))
|
|
306
411
|
return true;
|
|
307
412
|
return market.normalizedSymbol === undefined || tradesLargeQuotedInDollars(market.normalizedSymbol);
|
|
@@ -329,25 +434,30 @@ export function tradesBelowLargeFloor(print, market) {
|
|
|
329
434
|
}
|
|
330
435
|
/** Fold one raw TRADE point onto the tape rows: the NEW rows array (the touched row a new array,
|
|
331
436
|
* every other row shared by reference), or null when the point is rejected (the caller keeps
|
|
332
|
-
* its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid.
|
|
437
|
+
* its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid.
|
|
438
|
+
* A per-order tape (`options.perOrder`) folds its prints under no floor, the large-print table's
|
|
439
|
+
* included. */
|
|
333
440
|
export function mergeLiveTradesDataPoint(lastDataPoint, newPoint, intervalMs, options = {}) {
|
|
334
441
|
if (!Number.isFinite(intervalMs) || intervalMs <= 0)
|
|
335
442
|
return null;
|
|
336
443
|
const print = readLiveTradePrint(newPoint);
|
|
337
444
|
if (print === null)
|
|
338
445
|
return null;
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
446
|
+
const size = tradesTapeCellSize(print, options);
|
|
447
|
+
if (size === null)
|
|
341
448
|
return null;
|
|
342
|
-
if (options.largeFloor !== undefined &&
|
|
449
|
+
if (options.largeFloor !== undefined &&
|
|
450
|
+
options.perOrder !== true &&
|
|
451
|
+
tradesBelowLargeFloor(print, options.largeFloor)) {
|
|
343
452
|
return null;
|
|
453
|
+
}
|
|
344
454
|
const barTs = options.barTs ?? tradesBarStartMs(print.tsMs, intervalMs, print.exchange);
|
|
345
455
|
const rows = lastDataPoint;
|
|
346
456
|
const last = rows.length > 0 ? rows[rows.length - 1] : undefined;
|
|
347
457
|
// A delayed closed-bar print must not append an out-of-order row.
|
|
348
458
|
if (last && last[0] > barTs)
|
|
349
459
|
return null;
|
|
350
|
-
const cell = [print.tsMs - barTs, print.price,
|
|
460
|
+
const cell = [print.tsMs - barTs, print.price, size, print.side];
|
|
351
461
|
if (!last || last[0] !== barTs)
|
|
352
462
|
return [...rows, [barTs, cell]];
|
|
353
463
|
// Live folds receive a shallow snapshot copy: never mutate its shared row
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order gate of a per-order tape's live prints (BT-ORDER-FLOOR): the ONE rule the wrun intake's tape enqueue and the
|
|
3
|
+
* kScript fan-out of a `trades` source both apply, before their capped queues.
|
|
4
|
+
*
|
|
5
|
+
* Where the per-order switch holds (wrun-tape-per-order.util `wrunTapePerOrder`) a CME Group tape keeps its raw TRADE
|
|
6
|
+
* live channel and its floor judges ORDERS, as the gateway's per-order history read does. Consecutive same-side prints
|
|
7
|
+
* whose millisecond stamps sit within TRADES_ORDER_JOIN_MS of the print before form one order (Big Trades' "Combine
|
|
8
|
+
* fills: One order" rule, the kScript template's `joins`). The order is judged when a print of the other side or a
|
|
9
|
+
* later stamp arrives, or after TRADES_ORDER_HOLD_MS of quiet, so the last order of a quiet stretch is never held. It is
|
|
10
|
+
* judged by its total in the floor's unit (contracts under `minSize`, dollars under `minValue`, each print valued by
|
|
11
|
+
* `tradesTapeCellSize`): at or above the floor EVERY fill is admitted, so the package's combine sees them all; below it
|
|
12
|
+
* the order is dropped whole. A per-fill floor there drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills.
|
|
13
|
+
*
|
|
14
|
+
* The gateway keys an order by its exact exchange stamp and side, the gate by the package's combine group: the group
|
|
15
|
+
* holds every such order, so an admitted fill belongs to an order the per-order history at the same floor answers,
|
|
16
|
+
* except when two same-side orders within 1 ms each fall short of the floor and only their sum reaches it (the package
|
|
17
|
+
* draws them as one trade; the reconcile, which only adds prints to a bar, keeps them).
|
|
18
|
+
*
|
|
19
|
+
* Pure but for its hold timer: no store, no chart, worker-safe.
|
|
20
|
+
*/
|
|
21
|
+
import { type LiveTradePrint, type TradesTapeFloor } from './live-trades-merge.util.js';
|
|
22
|
+
/** The widest gap between two consecutive fills of one order, ms (the package's "One order" combine). */
|
|
23
|
+
export declare const TRADES_ORDER_JOIN_MS = 1;
|
|
24
|
+
/** How long the forming order waits for another fill before it is judged, ms. */
|
|
25
|
+
export declare const TRADES_ORDER_HOLD_MS = 50;
|
|
26
|
+
/** Where the gate's verdicts go: every fill of an order at or above the floor, or of one below it, in arrival order. */
|
|
27
|
+
export interface TradesOrderGateHooks<T> {
|
|
28
|
+
admit(items: readonly T[]): void;
|
|
29
|
+
drop(items: readonly T[]): void;
|
|
30
|
+
}
|
|
31
|
+
/** The floor a tape floor sets on an order's total, in the unit `tradesTapeCellSize` values a print in; 0 for none. */
|
|
32
|
+
export declare function tradesOrderGateThreshold(floor: TradesTapeFloor): number;
|
|
33
|
+
/** One tape's order gate (above): `push` each live print with the item the caller admits; `flush` judges the forming
|
|
34
|
+
* order now; `dispose` forgets it (a teardown, a new generation). */
|
|
35
|
+
export declare class TradesOrderGate<T> {
|
|
36
|
+
private readonly hooks;
|
|
37
|
+
private items;
|
|
38
|
+
private side;
|
|
39
|
+
private lastTsMs;
|
|
40
|
+
private total;
|
|
41
|
+
private threshold;
|
|
42
|
+
private timer;
|
|
43
|
+
constructor(hooks: TradesOrderGateHooks<T>);
|
|
44
|
+
/** The fills of the forming order, not judged yet. */
|
|
45
|
+
get held(): number;
|
|
46
|
+
/** Take one live print (`print`, read by `readLiveTradePrint`) under the tape's floor. A print the floor cannot value
|
|
47
|
+
* (a dollar floor without a unit, an option print its units cannot price) is dropped alone; with no floor the print
|
|
48
|
+
* is admitted at once, after the forming order. */
|
|
49
|
+
push(item: T, print: Pick<LiveTradePrint, 'tsMs' | 'price' | 'size' | 'side'>, floor: TradesTapeFloor): void;
|
|
50
|
+
/** Judge the forming order now: every fill admitted when its total reaches the floor, else every fill dropped. */
|
|
51
|
+
flush(): void;
|
|
52
|
+
/** Forget the forming order without a verdict. */
|
|
53
|
+
dispose(): void;
|
|
54
|
+
private arm;
|
|
55
|
+
private clearTimer;
|
|
56
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order gate of a per-order tape's live prints (BT-ORDER-FLOOR): the ONE rule the wrun intake's tape enqueue and the
|
|
3
|
+
* kScript fan-out of a `trades` source both apply, before their capped queues.
|
|
4
|
+
*
|
|
5
|
+
* Where the per-order switch holds (wrun-tape-per-order.util `wrunTapePerOrder`) a CME Group tape keeps its raw TRADE
|
|
6
|
+
* live channel and its floor judges ORDERS, as the gateway's per-order history read does. Consecutive same-side prints
|
|
7
|
+
* whose millisecond stamps sit within TRADES_ORDER_JOIN_MS of the print before form one order (Big Trades' "Combine
|
|
8
|
+
* fills: One order" rule, the kScript template's `joins`). The order is judged when a print of the other side or a
|
|
9
|
+
* later stamp arrives, or after TRADES_ORDER_HOLD_MS of quiet, so the last order of a quiet stretch is never held. It is
|
|
10
|
+
* judged by its total in the floor's unit (contracts under `minSize`, dollars under `minValue`, each print valued by
|
|
11
|
+
* `tradesTapeCellSize`): at or above the floor EVERY fill is admitted, so the package's combine sees them all; below it
|
|
12
|
+
* the order is dropped whole. A per-fill floor there drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills.
|
|
13
|
+
*
|
|
14
|
+
* The gateway keys an order by its exact exchange stamp and side, the gate by the package's combine group: the group
|
|
15
|
+
* holds every such order, so an admitted fill belongs to an order the per-order history at the same floor answers,
|
|
16
|
+
* except when two same-side orders within 1 ms each fall short of the floor and only their sum reaches it (the package
|
|
17
|
+
* draws them as one trade; the reconcile, which only adds prints to a bar, keeps them).
|
|
18
|
+
*
|
|
19
|
+
* Pure but for its hold timer: no store, no chart, worker-safe.
|
|
20
|
+
*/
|
|
21
|
+
import { tradesTapeCellSize, tradesTapeFloorIsDollars, } from './live-trades-merge.util.js';
|
|
22
|
+
/** The widest gap between two consecutive fills of one order, ms (the package's "One order" combine). */
|
|
23
|
+
export const TRADES_ORDER_JOIN_MS = 1;
|
|
24
|
+
/** How long the forming order waits for another fill before it is judged, ms. */
|
|
25
|
+
export const TRADES_ORDER_HOLD_MS = 50;
|
|
26
|
+
/** The floor a tape floor sets on an order's total, in the unit `tradesTapeCellSize` values a print in; 0 for none. */
|
|
27
|
+
export function tradesOrderGateThreshold(floor) {
|
|
28
|
+
const threshold = Number(tradesTapeFloorIsDollars(floor) ? floor.minValue : floor.minSize);
|
|
29
|
+
return Number.isFinite(threshold) && threshold > 0 ? threshold : 0;
|
|
30
|
+
}
|
|
31
|
+
/** One tape's order gate (above): `push` each live print with the item the caller admits; `flush` judges the forming
|
|
32
|
+
* order now; `dispose` forgets it (a teardown, a new generation). */
|
|
33
|
+
export class TradesOrderGate {
|
|
34
|
+
hooks;
|
|
35
|
+
items = [];
|
|
36
|
+
side = 0;
|
|
37
|
+
lastTsMs = Number.NaN;
|
|
38
|
+
total = 0;
|
|
39
|
+
threshold = 0;
|
|
40
|
+
timer;
|
|
41
|
+
constructor(hooks) {
|
|
42
|
+
this.hooks = hooks;
|
|
43
|
+
}
|
|
44
|
+
/** The fills of the forming order, not judged yet. */
|
|
45
|
+
get held() {
|
|
46
|
+
return this.items.length;
|
|
47
|
+
}
|
|
48
|
+
/** Take one live print (`print`, read by `readLiveTradePrint`) under the tape's floor. A print the floor cannot value
|
|
49
|
+
* (a dollar floor without a unit, an option print its units cannot price) is dropped alone; with no floor the print
|
|
50
|
+
* is admitted at once, after the forming order. */
|
|
51
|
+
push(item, print, floor) {
|
|
52
|
+
const value = tradesTapeCellSize(print, { ...floor, perOrder: true });
|
|
53
|
+
if (value === null) {
|
|
54
|
+
this.hooks.drop([item]);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const threshold = tradesOrderGateThreshold(floor);
|
|
58
|
+
if (threshold === 0) {
|
|
59
|
+
this.flush();
|
|
60
|
+
this.hooks.admit([item]);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const joins = this.items.length > 0 && print.side === this.side && Math.abs(print.tsMs - this.lastTsMs) <= TRADES_ORDER_JOIN_MS;
|
|
64
|
+
if (!joins) {
|
|
65
|
+
this.flush();
|
|
66
|
+
this.side = print.side;
|
|
67
|
+
this.total = 0;
|
|
68
|
+
}
|
|
69
|
+
this.items.push(item);
|
|
70
|
+
this.total += value;
|
|
71
|
+
this.lastTsMs = print.tsMs;
|
|
72
|
+
this.threshold = threshold;
|
|
73
|
+
this.arm();
|
|
74
|
+
}
|
|
75
|
+
/** Judge the forming order now: every fill admitted when its total reaches the floor, else every fill dropped. */
|
|
76
|
+
flush() {
|
|
77
|
+
this.clearTimer();
|
|
78
|
+
if (this.items.length === 0)
|
|
79
|
+
return;
|
|
80
|
+
const items = this.items;
|
|
81
|
+
const admitted = this.total >= this.threshold;
|
|
82
|
+
this.items = [];
|
|
83
|
+
this.total = 0;
|
|
84
|
+
if (admitted)
|
|
85
|
+
this.hooks.admit(items);
|
|
86
|
+
else
|
|
87
|
+
this.hooks.drop(items);
|
|
88
|
+
}
|
|
89
|
+
/** Forget the forming order without a verdict. */
|
|
90
|
+
dispose() {
|
|
91
|
+
this.clearTimer();
|
|
92
|
+
this.items = [];
|
|
93
|
+
this.total = 0;
|
|
94
|
+
}
|
|
95
|
+
arm() {
|
|
96
|
+
this.clearTimer();
|
|
97
|
+
this.timer = setTimeout(() => {
|
|
98
|
+
this.timer = undefined;
|
|
99
|
+
this.flush();
|
|
100
|
+
}, TRADES_ORDER_HOLD_MS);
|
|
101
|
+
}
|
|
102
|
+
clearTimer() {
|
|
103
|
+
if (this.timer !== undefined)
|
|
104
|
+
clearTimeout(this.timer);
|
|
105
|
+
this.timer = undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|