Skip to main content

BAZ.Palantir

BAZ.PALANTIR
// orchestration boundary · Rust

BAZ.Palantir

products/baz-palantir · rule lifecycle · enrichment · streaming

The Rust orchestration server at the centre of the BAZ trading platform. It validates and stores glither.hft rules, manages BAZ.CX market-data subscriptions, enriches incoming ticks and candles with technical indicators, and streams processed events to BAZ.Luna over WebSocket.

ORCHESTRATION · ENRICHMENT · RULES · WEBSOCKET · GRAPHQL · RUST

BAZ.Palantir sits between exchange feeds and the trading frontend. BAZ.CX streams raw ticks and candles in; BAZ.Palantir validates strategy rules, computes indicators from bounded ring buffers, and streams enriched events out to BAZ.Luna — all behind a constant-time bearer token boundary.


Enriched event stream​

The WebSocket endpoint /ws streams enriched candle, indicator, backlog, and signal events to BAZ.Luna. The mock below represents the kind of processed data the stream carries:

Data Streams · Live Feed
candle.enriched
17.7
indicator.batch
2.7
backlog.entry
36.0
signal.fired
7.3

Architecture​

BAZ.CX (:8000)
│ WebSocket: tick, candle, position
▼
BAZ.Palantir (:8080) Rust · Axum · SQLite
│
├── Rule lifecycle PUT /api/rules/{name}
│ baz-hft-roux validation in-process
│ SQLite transactional store
│
├── Subscription mgr POST /api/subscribe
│ desired-set registry outside socket sessions
│ exponential-backoff reconnect to BAZ.CX
│
├── Enricher bounded ring buffers
│ SMA · EMA · RSI · Bollinger · volume ratios
│ candle range · price-to-SMA · bid/ask spread
│
└── WS/REST/GraphQL /ws · /api/* · /graphql
bearer auth on all non-health endpoints
/api/health is the only public endpoint
│
▼
BAZ.Luna (:5173)
WebSocket: candle · indicator · backlog · signal
REST: rule CRUD · daemon control · candle snapshots
✓LOOPBACK BY DEFAULT

Palantir binds to 127.0.0.1:8080. Binding to 0.0.0.0 is appropriate only behind an authenticating proxy or private network. CORS is not enabled permissively.


Rule lifecycle​

A

Rule lifecycle

1
glither.hft rules stored and validated in-process

BAZ.Palantir is the authoritative store for compiled glither.hft strategy rules. When BAZ.Luna POSTs a rule, Palantir runs the full compiler pipeline in-process via the baz-hft-roux facade before committing anything to SQLite.

1

Author .glith source in BAZ.Luna CodeMirror editor POST rule source to PUT /api/rules/{name} — Palantir runs baz-hft-roux parse + check Compilation summary returned: symbols, windows, indicators derived from source Rule stored transactionally in SQLite on success POST /api/subscribe — Palantir derives required market-data symbols and registers them with BAZ.CX BAZ.CX begins streaming ticks and candles for subscribed symbols Enriched events flow over /ws to BAZ.Luna; backlog entries logged to SQLite

Rule names are bounded ASCII — path traversal is prevented at the store layer. The compilation summary is a structured value, not a shell invocation.


HTTP and WebSocket surfaces​

B

API surfaces

2
authenticated on all non-health endpoints
GET /api/health— (public)Liveness check — the only unauthenticated endpoint
GET /api/rulesBearerList stored rule names
GET /api/rules/{name}BearerRead rule source
PUT /api/rules/{name}BearerValidate (baz-hft-roux) and store rule
DELETE /api/rules/{name}BearerRemove rule and clear subscriptions
POST /api/rules/{name}/compileBearerParse, check, and return compilation summary
POST /api/subscribeBearerResolve validated source market-data requirements
GET /api/backlogBearerRead SQLite backlog entries
GET /api/candlesBearerRead bounded candle history
GET /api/daemon/statusBearerRead daemon state
POST /api/daemon/{action}BearerStart, stop, attach, or detach daemon
WS /wsBearerStream enriched events: candle, indicator, backlog, signal
GET,POST /graphqlBearerGraphQL query and mutation surface
curl -H "Authorization: Bearer $PALANTIR_API_TOKEN" \
http://127.0.0.1:8080/api/rules

Enrichment​

C

In-process enrichment

3
bounded ring buffers, subscribed signals only

The enricher computes technical indicators from bounded ring buffers populated with candle data. It only computes signals for subscribed symbols — no work is done for market data that no active rule references.

307032RSI(14) · BTC/USDneutral
307061RSI(14) · ETH/USDTneutral
SMA · EMA · rings
SMA(9)
62.0
SMA(21)
55.0
EMA(12)
68.0
Bollinger · spread
BB upper
81.0
BB lower
24.0
spread %
18.0
SMA, EMASimple and exponential moving averages over ring buffer windows.
RSIRelative Strength Index — standard 14-period, single-pass, no heap.
Bollinger BandsUpper, lower, and mid bands from μ ± dev·σ on the close ring.
Volume ratiosCurrent bar volume vs. ring-buffer mean volume.
Candle rangeHigh–low range for each candle, added to the enriched event.
Price-to-SMARatio of current price to slow SMA — trend distance signal.
Bid/ask spread %(ask − bid) / mid · 100 — execution cost proxy.

Storage​

D

SQLite storage

4
rules · candles · backlog · operational audit
RulesValidated glither.hft source stored transactionally. Name-indexed, bounded ASCII.
CandlesBounded candle history per subscribed symbol. Read via GET /api/candles.
BacklogTimestamped signal log written by `then_log backlog` rule directives. Not canonical monetary evidence.
Rule auditOperational audit trail of compile, store, delete, and subscription events.
⚠AUDIT BOUNDARY

The SQLite backlog is a lossy diagnostic store — it is not the canonical monetary audit trail. Signed monetary receipts (Ed25519, content-addressed, append-only chain) live in the BAZ.HFT host crate and are not yet durably integrated into BAZ.Palantir. Order execution cannot be enabled until that integration is complete.


WIT signal types​

BAZ.Palantir's WebSocket events use types derived from the glither.hft WIT world:

package glither:hft;

interface hft-types {
record tick {
price: float32,
volume: float32,
timestamp: uint64,
bid: float32,
ask: float32,
}
record position {
entry-price: float32,
current-price: float32,
quantity: float32,
unrealized-pnl: float32,
}
variant action {
market-buy(string),
market-sell(string),
limit-buy(string),
limit-sell(string),
market-close-all(string),
cancel(string),
modify-to-market,
noop,
}
record receipt {
action: action,
reason: string,
timestamp: uint64,
}
}

The BAZ.Palantir WebSocket stream adds enriched fields (indicator values, ring buffer snapshots, backlog entries) on top of the raw WIT types.


Run and verify​

# Environment
cp .env.example .env
set -a; . ./.env; set +a

# Run
cargo run

# Verify
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targets

Palantir uses sibling path dependencies on ../baz.hft and ../glither. The container build context is the parent experiments/ directory so the image can include both sibling compiler crates.


Current limitations and next steps​

No venue executionNo order submission or settlement integration. Live-trading is not enabled.
No durable receiptsSigned monetary receipts (BAZ.HFT host crate) not yet integrated into Palantir storage.
No key managementNo key-rotation service. Token is a single static env var.
Daemon controlsAn orchestration boundary only — not a production supervisor.
Latency unmeasuredSub-millisecond enrichment is a design target; not yet benchmarked on a live feed.

See BAZ.HFT for dialect ownership and the signed receipt chain, and BAZ architecture for the full platform overview including BAZ.CX and BAZ.Luna.