Skip to main content

BAZ.HFT

BAZ.HFT
// systematic signal processing

BAZ.HFT

products/baz-hft · glither.hft dialect · host runtime · audit receipts

The glither.hft dialect and host embryo for deterministic market-policy evaluation. BAZ.HFT owns strategy fixtures, host integration, execution controls, and signed monetary audit receipts built on the RAGBAZ stack.

GLITHER.HFT · INDICATORS · OSCILLATORS · AUDIT · WASM · RECEIPTS

BAZ.HFT is the Glither dialect and host embryo for deterministic market-policy evaluation. The compiler is shared with Glither; BAZ.HFT owns the HFT-specific strategy fixtures, transact lifecycle model, signed monetary receipt chain, and host integration boundary.


Live Indicator Suite

The indicator suite below is fully interactive. Select a timeframe and observe how RSI, Stochastic, MACD, and moving average signals update across the chart.

BAZ.HFT · INDICATOR SUITE
HOLD
BAZ/USD · 1H
145.29-0.27%BB20SMA20SMA50
T-60hNOW
Volume
307051RSI · 14neutral
Stochastic 14/3
%K
49.4
%D
66.1
MACD 12/26/9
MACD0.312
Signal0.348
Hist-0.036
MACD12 / 26 / 9
── signal── macd
Indicator Summary
IndicatorPeriodValueSignal
SMA20145.34below
SMA50144.86above
RSI1450.7neutral
Stoch %K1449.4neutral
MACD Hist12/26/9-0.036bearish

Architecture

.glith strategy source


baz-hft-roux (Glither compiler facade)
│ pest PEG parse · IR lower · structural checks

Codegen → no_std Rust WASM component · WIT contract

├── State structs — heapless ring buffers per state definition
├── Math macros — rsi(), μ(), σ(), bbands_*() single-pass, no heap
└── Dispose fns — dispose_tick(ctx) → Receipt
dispose_position(ctx) → Receipt


BAZ.Palantir (rule storage · enrichment · subscriptions · streaming)


BAZ.Luna (candlestick charts · backlog viewer · notebook editor)
OWNERSHIP SPLIT

BAZ.HFT does not carry its own compiler fork. The parser, IR, checks, and Rust/WIT codegen live in Glither packages/roux. BAZ.HFT adds the HFT compatibility facade (baz-hft-roux), strategy fixtures, host runtime stub, and the signed monetary receipt chain.


Indicators

A

Trend Indicators

1
directional, non-bounded

Trend indicators track the prevailing direction of price. They are non-bounded — their values are expressed in price units and have no fixed range.

SMA(n)Simple Moving Average — equal-weight mean of last n closes. Cheap, lag-heavy, foundational.
EMA(n)Exponential Moving Average — recency-weighted with factor k=2/(n+1). Less lag than SMA.
VWAPVolume-Weighted Average Price — intraday anchored mean. Institutional reference.
Bollinger(n, σ)Band envelope: SMA(n) ± σ·std(n). Volatility-relative price position.
ATR(n)Average True Range — mean of |High-Low|, |High-Close|, |Low-Close|. Volatility magnitude.
Donchian(n)Highest high / lowest low channel over n bars. Breakout reference.
B

Oscillators

2
bounded, mean-reverting

Oscillators are bounded — they return values in a fixed range and are designed to identify overbought / oversold conditions and divergences.

RSI(14)Relative Strength Index — ratio of average gains to average losses over n bars. Range [0, 100]. Overbought >70, oversold <30.
Stochastic(14, 3)%K = position within recent H/L range; %D = SMA(%K, 3). Range [0, 100]. Oversold <20, overbought >80.
CCI(20)Commodity Channel Index — (price - SMA) / (0.015 · mean deviation). Range typically ±200.
Williams %R(14)Inverted Stochastic %K. Range [-100, 0]. Oversold < -80, overbought > -20.
Momentum(10)Price - Price[n]. Rate of change in price units. Sign = direction, magnitude = speed.
ROC(10)Rate of Change as percentage: (price/price[n] - 1) × 100. Normalized momentum.
307068RSI · 14neutral
307027Stoch %Koversold
307052CCI normneutral

DSL Syntax

BAZ.HFT uses the glither.hft dialect. Rules declare bounded ring-buffer state, apply inline math macros, and emit typed transact dispositions with two-stage fill/timeout lifecycle arms:

#pragma dialect glither.hft ; fold first-match
#pragma version 2.0-beta

state noise_rsi = bars | window = 14 | timeframe = 1m | tracks = [ close ]
state noise_bb = bars | window = 20 | timeframe = 1m | tracks = [ close, volume ]

rule rsi_oversold_reversal =
tick | rsi(noise_rsi.close) < 25.0
| tick.close < bbands_lower(noise_bb.close, dev = 2.5)
| volume(noise_bb.volume) > μ(noise_bb.volume)
=> transact market_buy
on fill into position(target = bbands_mid(noise_bb.close))
after 30s market_close_all (reason = mean_reversion_timeout)
then_log backlog

State definitions

state declares a named ring buffer. BAZ.Palantir's enricher populates it from the BAZ.CX market-data stream for each subscribed symbol.

FieldPurpose
window = NRing buffer capacity (bars kept)
timeframe = 1mBar resolution fed into the ring
tracks = [close]Fields populated per bar

Math macros

MacroDescription
rsi(path)RSI(14) over the ring buffer
μ(path)Arithmetic mean
σ(path, m)Standard deviation (takes pre-computed mean)
volume(path)Sum over window
bbands_upper(path, dev)Upper Bollinger Band (mean + dev·σ)
bbands_lower(path, dev)Lower Bollinger Band (mean − dev·σ)
bbands_mid(path)Middle Bollinger Band (= mean)

Transact lifecycle

transact <order_type>
on <event> into <lifecycle_action> -- on fill
after <duration> <lifecycle_action> -- on timeout
then_log backlog -- timestamp signal to SQLite

Every transact disposition embeds a two-stage lifecycle so the host (BAZ.Palantir) knows how to handle fill and timeout cases without any shell process or external scheduler.

iAUDIT BOUNDARY

then_log backlog is a lossy diagnostic directive — it timestamps signals to the SQLite backlog. It is not the canonical monetary audit store. Signed receipts (Ed25519, content-addressed, append-only chain) live in the BAZ.HFT host crate and require durable integration before order execution is enabled.


Optimizations

Incremental computation

Indicators are incremental — on each new bar, only the delta is recomputed:

IndicatorIncremental formComplexity
SMA(n)Sum window: add new, drop oldestO(1)
EMA(n)prev_ema × (1-k) + price × kO(1)
RSI(n)Wilder smoothing on avg gain/lossO(1)
Stochastic(k, d)Sliding H/L windowO(1) amortized
ATR(n)EMA of true rangeO(1)
MACDThree cascaded EMAsO(1)

Compile-time selector pushdown

The Glither compiler infers cheap selectors from crossing-guard predicates. In the example above, | bar in trending and | rsi14 < 35 are pushed into an indexed pre-filter before the more expensive crosses_above check — identical to the SQL optimiser pattern in the core spec.

SIMD batch evaluation

For bulk backtesting, BAZ.HFT compiles indicator compute graphs to WASM SIMD instructions (v128 operations). A 10-year daily bar series computes all indicators in < 40ms on a single core.


Next steps

Current status: compiler and audit primitives implemented; live execution not enabled.

ItemDescription
Durable receiptsAppend and synchronize signed receipts before any venue side effect
Event emissionEmit policy compilation and activation receipts
Lifecycle eventsConnect plan, review, submit, fill, cancel, and settlement events
Durable storageAppend-only storage, key rotation, retention policy
Replay toolingReplay tooling and redacted operator/regulator projections
Latency benchmarkMeasure component latency and allocation under a paper feed

Technology Stack

LayerTechnology
Dialectglither.hft (extends Glither packages/roux)
Compiler facadebaz-hft-roux re-exports shared Glither compiler API
Runtime codegen#![no_std] Rust WASM component, heapless::Vec ring buffers
WIT contractworld hft-executordispose-tick, dispose-position
Audit receiptsEd25519 · content-addressed IDs · SHA-256 chain · append-only
OrchestrationBAZ.Palantir (rule storage, subscriptions, enrichment, streaming)
FrontendBAZ.Luna (candlestick charts, CodeMirror editor, backlog viewer)

See the BAZ architecture experiment page for the full compiler pipeline, IR types, WIT world definition, and example strategies.