Appearance

Personalize your experience

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

QuaScript Documentation

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

hft

Generated from the engine catalog by tools/gen-docs.mjs; do not edit.

hft.amihud

script.qs
hft.amihud(len = 20, scale = 1000000) -> series

Amihud illiquidity: mean |return| / traded value over len bars, times scale.

ArgumentKindDefaultNotes
lenint20
scalenum1000000

Keeps state per call site.

hft.bipower

script.qs
hft.bipower(src = close, len = 20) -> (realized, bipower, jump)

Realized vs bipower volatility (percent) and the jump share of variance (0 .. 1).

ArgumentKindDefaultNotes
srcseriesclose
lenint20

Returns 3 values: realized, bipower, jump. Keeps state per call site.

script.qs
(rv, bv, jump) = hft.bipower(close, 50)

hft.corwin_schultz

script.qs
hft.corwin_schultz(len = 20) -> series

Corwin-Schultz high-low bid-ask spread estimate, averaged over len bars, in percent of price.

ArgumentKindDefaultNotes
lenint20

Keeps state per call site.

hft.cusum

script.qs
hft.cusum(src = close, threshold = 0, len = 50, mult = 2) -> int

Symmetric CUSUM filter: 1 / -1 when the cumulative change passes the threshold (0 = mult x stdev of changes over len), else 0.

ArgumentKindDefaultNotes
srcseriesclose
thresholdnum0
lenint50
multnum2

Keeps state per call site.

hft.efficiency

script.qs
hft.efficiency(src = close, len = 20) -> series

Efficiency ratio: net move over the path length of the last len bars (0 noise .. 1 straight line).

ArgumentKindDefaultNotes
srcseriesclose
lenint20

Keeps state per call site.

hft.ewm_zscore

script.qs
hft.ewm_zscore(src, halflife = 20) -> series

Exponentially weighted z-score with the given half-life in bars (O(1), no window).

ArgumentKindDefaultNotes
srcseriesrequired
halflifenum20

Keeps state per call site.

hft.ewma_vol

script.qs
hft.ewma_vol(src = close, lambda = 0.94, annual = 252) -> series

Exponentially weighted (RiskMetrics) volatility of log returns. Percent; annual = bars per year (0 = per bar).

ArgumentKindDefaultNotes
srcseriesclose
lambdanum0.94
annualnum252

Keeps state per call site.

hft.flow

script.qs
hft.flow(len = 20) -> (buy, sell, imbalance)

Buy and sell volume of the bar (host order flow when supplied, else bulk volume classification) and the net imbalance over len bars (-1 .. 1).

ArgumentKindDefaultNotes
lenint20

Returns 3 values: buy, sell, imbalance. Keeps state per call site.

script.qs
(buy, sell, imb) = hft.flow(20)

hft.garch

script.qs
hft.garch(src = close, alpha = 0.05, beta = 0.9, annual = 252) -> (vol, long_run)

GARCH(1,1) next-bar volatility forecast with variance targeting: (vol, long_run). Percent; annual = bars per year (0 = per bar).

ArgumentKindDefaultNotes
srcseriesclose
alphanum0.05
betanum0.9
annualnum252

Returns 2 values: vol, long_run. Keeps state per call site.

hft.garman_klass

script.qs
hft.garman_klass(len = 20, annual = 252) -> series

Garman-Klass OHLC volatility over len bars. Percent; annual = bars per year (0 = per bar).

ArgumentKindDefaultNotes
lenint20
annualnum252

Keeps state per call site.

hft.hawkes

script.qs
hft.hawkes(event, decay = 0.1, jump = 1, base = 0) -> series

Self-exciting (Hawkes) intensity: decays by exp(-decay) per bar and jumps on every event.

ArgumentKindDefaultNotes
eventboolrequired
decaynum0.1
jumpnum1
basenum0

Keeps state per call site.

script.qs
heat = hft.hawkes(math.abs(ta.change(close)) > 2 * ta.atr(14), 0.2)

hft.jump_test

script.qs
hft.jump_test(src = close, len = 50, alpha = 0.01) -> (stat, jump)

Lee-Mykland jump test: the return over the bipower volatility of the previous len returns (stat) and 1 / -1 when it is a jump at significance alpha, else 0.

ArgumentKindDefaultNotes
srcseriesclose
lenint50
alphanum0.01

Returns 2 values: stat, jump. Keeps state per call site.

script.qs
(lm, jump) = hft.jump_test(close, 50, 0.01)

hft.kalman_beta

script.qs
hft.kalman_beta(a, b, delta = 0.0001, noise = 0.001) -> (beta, alpha, spread, zscore)

Kalman-filter regression a = alpha + beta * b with time-varying coefficients: (beta, alpha, spread, zscore) for pairs and hedging.

ArgumentKindDefaultNotes
aseriesrequired
bseriesrequired
deltanum0.0001
noisenum0.001

Returns 4 values: beta, alpha, spread, zscore. Keeps state per call site.

script.qs
(beta, alpha, spread, z) = hft.kalman_beta(close, ta.ema(close, 50))

hft.kyle_lambda

script.qs
hft.kyle_lambda(len = 50, scale = 1000000) -> series

Kyle's lambda: price impact per unit of signed volume (regression over len bars), times scale.

ArgumentKindDefaultNotes
lenint50
scalenum1000000

Keeps state per call site.

hft.ou

script.qs
hft.ou(src, len = 100) -> (mean, half_life, zscore)

Ornstein-Uhlenbeck fit (AR(1) over len bars): (equilibrium mean, half-life in bars, z-score); na while the window is not mean-reverting.

ArgumentKindDefaultNotes
srcseriesrequired
lenint100

Returns 3 values: mean, half_life, zscore. Keeps state per call site.

script.qs
(mu, hl, z) = hft.ou(close, 120)

hft.parkinson

script.qs
hft.parkinson(len = 20, annual = 252) -> series

Parkinson high-low volatility over len bars. Percent; annual = bars per year (0 = per bar).

ArgumentKindDefaultNotes
lenint20
annualnum252

Keeps state per call site.

script.qs
v = hft.parkinson(20, 252)

hft.realized_vol

script.qs
hft.realized_vol(src = close, len = 20, annual = 0) -> series

Realized volatility: sqrt of the sum of squared log returns over len bars, in percent; annual > 0 annualises the mean instead.

ArgumentKindDefaultNotes
srcseriesclose
lenint20
annualnum0

Keeps state per call site.

hft.rogers_satchell

script.qs
hft.rogers_satchell(len = 20, annual = 252) -> series

Rogers-Satchell drift-independent OHLC volatility over len bars. Percent; annual = bars per year (0 = per bar).

ArgumentKindDefaultNotes
lenint20
annualnum252

Keeps state per call site.

hft.roll_spread

script.qs
hft.roll_spread(len = 20, src = close) -> series

Roll effective spread from the serial covariance of price changes (price units, 0 when the covariance is positive).

ArgumentKindDefaultNotes
lenint20
srcseriesclose

Keeps state per call site.

hft.runs_test

script.qs
hft.runs_test(src = close, len = 50) -> (zscore, runs)

Wald-Wolfowitz runs test of the signs of the last len changes: z < 0 when moves cluster (trending), z > 0 when they alternate (mean-reverting); and the number of runs.

ArgumentKindDefaultNotes
srcseriesclose
lenint50

Returns 2 values: zscore, runs. Keeps state per call site.

script.qs
(rz, runs) = hft.runs_test(close, 50)

hft.semivariance

script.qs
hft.semivariance(src = close, len = 20) -> (up, down, signed)

Realized semivariance of the last len log returns: upside and downside volatility (percent) and their balance (up - down) / (up + down) in -1 .. 1.

ArgumentKindDefaultNotes
srcseriesclose
lenint20

Returns 3 values: up, down, signed. Keeps state per call site.

script.qs
(up, down, bal) = hft.semivariance(close, 50)

hft.variance_ratio

script.qs
hft.variance_ratio(src = close, len = 100, q = 4) -> series

Lo-MacKinlay variance ratio of q-bar to 1-bar returns (> 1 trending, < 1 mean-reverting).

ArgumentKindDefaultNotes
srcseriesclose
lenint100
qint4

Keeps state per call site.

hft.vpin

script.qs
hft.vpin(buckets = 50, bucket_volume = 0, warmup = 50) -> series

Volume-synchronised probability of informed trading (0 .. 1) over the last buckets volume buckets; bucket_volume = 0 uses the average bar volume of the first warmup bars.

ArgumentKindDefaultNotes
bucketsint50
bucket_volumenum0
warmupint50

Keeps state per call site.

script.qs
toxicity = hft.vpin(50)

hft.yang_zhang

script.qs
hft.yang_zhang(len = 20, annual = 252) -> series

Yang-Zhang volatility (overnight + open-close + Rogers-Satchell), robust to gaps. Percent; annual = bars per year (0 = per bar).

ArgumentKindDefaultNotes
lenint20
annualnum252

Keeps state per call site.


© 2026 Quatick Technologies. All rights reserved.