Appearance

Personalize your experience

Mode
Accent Color
Direction
All Docs/QuaScript//
QuaScript logo

QuaScript Documentation

Language guide, engine API, 675 builtins and the preset library · v3.0.0-phase1

Enterprise microstructure indicators

The thirty analyses in presets/analysis/hft/enterprise/ separate displayed liquidity, observed order flow, calibrated transition estimates and execution diagnostics. They run in the native C++ engine and publish numeric series, bounded status tables and chart visuals. Missing observations produce na and an availability message; they are never reconstructed from candle direction or volume. The library is analytical infrastructure; calibration and execution quality must be evaluated on the deployment's own feeds and latency.

Event sessions

The normal terminal book path supplies one snapshot per chart bar. Its snapshots support depth geometry, displayed sweep costs and concentration. Temporal indicators require a separate immutable event session: one observation per sequenced source event, containing the reconstructed book after that event. Equal exchange timestamps remain separate rows.

data.json
{"op":"open","session":"microstructure","script":"analysis \"Flow\" {}\n(a,b,c)=hft.ofi()\nrender.histogram(a)","eventMode":true,"maxObservations":250000,"bars":{"time":[1700000000],"open":[100],"high":[100],"low":[100],"close":[100],"volume":[0],"book":[{"bids":[[99.99,10]],"asks":[[100.01,12]]}],"host":{"event.sequence":[100],"event.time":[1700000000],"event.receive_time":[1700000000.001],"event.reset":[1]}}}

Send subsequent complete batches with op = "append_events", the same session, and a bars object in the same column format. JSON arrays and base64 Float64 columns are supported. The authenticated /api/quascript/session route exposes both operations and scopes sessions to the caller. quas serve provides the same protocol directly. Asset tick_size must match the instrument; quantities, fee units and any cross-venue conversion must also match.

Transport rules:

  • event.sequence is a nonnegative safe integer, increasing strictly between resets. Use a session-local lossless sequence mapping if exchange IDs exceed Float64's integer range.
  • time and event.time are identical, nondecreasing epoch seconds, with fractional seconds preserved. event.receive_time is finite epoch seconds on a synchronized clock.
  • The first row requires event.reset = 1 and a two-sided reconstructed book. A reset may restart the sequence number; it cannot move the observation clock backward.
  • The engine derives event.valid. A sequence discontinuity or explicit event.gap = 1 latches the feed invalid until a new full snapshot with event.reset = 1. Temporal state resets across that boundary. A dropped event must never be concealed by renumbering it.
  • Event history is immutable: append and update_last are rejected for event sessions. Bar-based feeds and backtest strategies are rejected in event mode.
  • A batch is validated before changing the session. Default capacity is 250,000 observations; maxObservations accepts 1..2,000,000. At capacity the engine rejects additional rows. Hosts must manage bounded replay windows explicitly; reopening a window restarts calibration.
  • The event host schema is fixed at open, with at most 128 columns. Declare optional channels as null-filled columns initially; introducing columns later is rejected to avoid historical padding on a live update. Every event batch must contain at least one observation.
  • maxInputBytes caps retained input payload storage (default 128 MiB, range 64 KiB..512 MiB). Admission includes books and the fixed host schema. Allocator overhead and retained output series are additional; the observation cap bounds output history independently.

Host observation contract

All columns live in bars.host, aligned one-for-one with the observation rows. Missing columns remain absent, not zero. Columns representing event increments must explicitly contain zero on events where that activity did not occur.

ColumnsMeaning
event.kind0 other, 1 addition, 2 modification, 3 cancellation, 4 execution; requires an explicitly typed source feed
event.sideResting book side: -1 bid, +1 ask
event.qty, event.priceQuantity affected by the typed event and its absolute price
trade.buy_volume, trade.sell_volume, trade.countExecuted aggressor-buy/sell quantity and trade count in this observation; use exchange attribution where available
own.order_id, own.sideStable tracked order identity and +1 buy / -1 sell action side; IDs must be safe integers
own.fill_qty, own.fill_priceIncremental own fill quantity and execution price; zero quantity when no fill
own.queue_ahead, own.remaining_qty, own.priority_validObserved displayed priority and remaining quantity; priority_valid=1 only when the venue/own-order adapter can establish it
own.inventorySigned actual inventory in the same quantity units as the book
venue.bid, venue.ask, venue.bid_size, venue.ask_sizeExecutable remote touch quotes and quantities, already converted into the local instrument's units
venue.age_ms, venue.fee_bpsRemote quote age in milliseconds and one-way fee in basis points
model.drift_ticksHost-calibrated expected signed mid displacement at the host model's documented horizon, in instrument ticks

Own-order fill and queue statistics require identity continuity. MBO snapshots by themselves do not establish own queue priority: the adapter must apply venue matching rules, priority changes and own acknowledgements. An order change censors incomplete order episodes rather than assigning another order's fills to the previous observation. Snapshot depth changes do not identify additions, cancellations or executions.

Catalog and interpretation

AnalysisNative calculationRequired observations
Calibrated Microprice Surfacehft.micropriceContinuous event book; matured next-event transitions
Depth Pressure Spectrumhft.depth_pressureDisplayed book
Liquidity Cliff Atlashft.liquidity_cliffsDisplayed price levels
Sweep Cost Surfacehft.sweep_costDisplayed depth and explicit quantity
Depth Concentration Fragilityhft.concentrationDisplayed quantities
Spread-to-Risk Gaugehft.spread_riskBook, causal volatility and fee assumptions
Depth-Normalized OFIhft.ofiContinuous event book
Persistent Liquidity Maphft.persistenceContinuous event book and clock
Liquidity Withdrawal Monitorhft.withdrawalContinuous event book with visible coverage
Shock Recovery Clockhft.recoveryContinuous event depth and clock
Liquidity Migration Trackerhft.migrationContinuous event depth
Flow Transmission Residualhft.flow_residualContinuous event book
Aggressor Flow Spectrumhft.aggressorContinuous events and explicit trades
Absorption Evidence Maphft.absorptionEvents, trades and displayed book
Queue Exhaustion Probabilityhft.exhaustionMatured conditional quote transitions
Impact Asymmetry Meterhft.impactObserved trades and subsequent book mid
Trade Burst Detectorhft.trade_burstTrade increments and clock
Post-Trade Refill Efficiencyhft.refillTrades and typed additions at consumed prices
Adverse Selection Landscapehft.adverse_selectionOwn fill increments and subsequent book mid
Fill-versus-Drift Frontierhft.fill_driftStable own order identity and observed fills
Queue Progress Monitorhft.queue_progressActual tracked displayed priority
Latency Erosion Curvehft.latency_decayMatured delayed event observations
Net Execution Edge Corridorhft.execution_edgeCalibrated host forecast, depth and fees
Inventory Exit Capacityhft.inventory_exitActual inventory and displayed depth
Volatility–Liquidity Regime Atlashft.regimeContinuous events and causal volatility
Range-Break Fragilityhft.range_fragilityCompleted range boundaries and covering visible depth
Participation Surprisehft.participationExplicit trades, typed events and clock
Order Lifecycle Fluxhft.lifecycleExplicit typed lifecycle events
Cross-Venue Executable Dislocationhft.cross_venueComparable fresh remote quotes, size and fees
Feed Integrity and Signal Validityhft.validityBook and transport metadata

hft.microprice is a causal next-event conditional mid forecast, not the full infinite-horizon Markov-limit estimator. Its error band describes calibration dispersion/standard error, not a guaranteed price interval. Exhaustion probabilities describe next-event bid-down / ask-up transitions, a quote-depletion proxy. Calibration outputs stay na until sufficient labels have matured. len controls a bounded effective EW learning window, not a fixed rolling sample.

Markout horizons and latency delays are measured in immutable event observations, not milliseconds. An event-delay curve must not be presented as a measured deployment latency curve; compare it with separately measured wall-clock transport and execution times. Favorable markouts are signed positively; adverse-selection cost has the opposite sign. Descriptive stress, fragility and absorption scores are not calibrated probabilities.

Sweep costs include distance from the mid. The sweep returns na cost when the visible book cannot fill the entire requested quantity, together with the available fill fraction. Execution edge deducts that crossing cost and one-way fees from the supplied forecast, so spread is not deducted twice. Snapshot costs describe displayed liquidity at that observation.

Performance and verification

See the measured performance report for the reference environment, individual latency percentiles, observed tails and measurement limits.

Event sessions append only changed observations and return only the resulting output tail. Their normal path does not copy forming-bar checkpoints. Calibration uses bounded state, bounded event-horizon rings and visible-depth scans, with no historical-series scan per update. Retained input/output history is bounded by the session capacity. Rendering runs separately from calculation; plot backend selection is a chart concern, not a signal-processing delay.

terminal.sh
python3 tests/enterprise_hft_test.py
python3 tests/enterprise_bench.py

The tests use explicitly synthetic host observations to check independent book arithmetic, causal prefixes, missing-data behavior, sequence-gap/reset handling and JSON/base64 incremental equivalence for every preset. The benchmark reports worker execution and transport separately, including percentile latency. These checks do not establish predictive profitability or a zero-latency guarantee. Record the compiler, hardware, dataset, book depth and event batch size when comparing results.


© 2026 Quatick Technologies. All rights reserved.