Deterministic scripts
The processing chain from raw data to journal, the ten script categories, the risk-validation pipeline with machine-readable rejection codes, and the AI boundaries.
The quantitative core is a chain of deterministic scripts, not one model. Each is pure where possible, versioned, replayable and unit-tested — and the AI sits above them, never inside the path that computes a number or approves a trade.
The processing chain
Every layer has one responsibility. A strategy never calls an exchange; an indicator never decides to trade; the executor never edits strategy logic; the AI never bypasses the risk engine.
- Raw market dataCollected from venues via CCXT and on-chain
- Validation → normalized dataGaps, duplicates, impossible prices rejected
- IndicatorsPure functions from the mathematical library
- Strategy conditions → signal candidateVersioned strategy logic only
- Liquidity & risk validationSlippage, sizing, exposure, circuit breakers
- Execution intent → orderExchange precision, idempotency, reconciliation
- Position monitoring → exitStops, targets, invalidation
- Trade journal → performanceEvery signal and trade, with versions
The ten script categories
| Category | Responsibility |
|---|---|
| Data collection | Connect to venues, collect OHLCV / trades / books / fees / limits, normalize timestamps |
| Data validation | Duplicates, impossible prices, gaps, stale books, data-quality scores |
| Indicators | Pure, typed functions with declared minimum history and unit tests |
| Signal | Combine indicators into a candidate with reasons — never places an order |
| Risk | Planned loss, position size, limits, stop & liquidity validation, breakers |
| Execution | Translate intents to venue orders, retries, idempotency, reconciliation |
| Position monitoring | Exposure, stops/targets, trailing, emergency exit |
| Backtesting | Replay without look-ahead, simulate fills/fees/slippage/latency, metrics |
| Research | Parameter grids, walk-forward, sensitivity, overfitting detection, reports |
| Journal | Record every signal/trade/rejection with strategy and formula versions |
Data validation invariants
Normalized candles must satisfy, in code:
- Low ≤ Open ≤ High and Low ≤ Close ≤ High;
- High ≥ Low and Volume ≥ 0;
- no duplicate, out-of-order or impossible-price candles;
- order books that are not stale relative to the venue clock.
The risk-validation pipeline
A signal candidate becomes an approved execution intent only after every gate passes:
- Validate strategy & data freshnessState, market-data age, venue status
- Validate market rules & liquidityTradable, depth, expected slippage
- Stop distance → position sizeRisk-first, bounded by every limit
- Validate balance & exposureAvailable quote, portfolio heat
- Validate daily/weekly risk & breakersLimits and circuit-breaker state
- Approved intent or rejectionWith machine-readable codes
Rejections are machine-readable, so the rejected-signal journal can be analyzed later:
| Code | Code |
|---|---|
| STALE_MARKET_DATA | SPREAD_TOO_WIDE |
| SLIPPAGE_TOO_HIGH | INSUFFICIENT_BALANCE |
| MAX_DAILY_LOSS_REACHED | MAX_PORTFOLIO_HEAT_REACHED |
| POSITION_TOO_SMALL | POSITION_TOO_LARGE |
| VENUE_RESTRICTED | MARKET_NOT_TRADABLE |
| STOP_INVALID | DATA_QUALITY_TOO_LOW |
| CIRCUIT_BREAKER_ACTIVE | … |
Versioning & determinism
Every important formula set carries a version (position_sizing_v1, atr_stop_v2, slippage_model_v2, …). Historical definitions are never overwritten in place, so a trade stays reproducible after formulas change. The engine is deterministic, versioned, observable and conservative when data is incomplete.