Fouad Salkini
Fouad SalkiniTech Lead & Architect
Published on 2026-10-10 12:45•86 views•Part 3 of Algorithmic Systems & Quant Architecture

Sub-100ms High-Frequency Trading: Building on Jev, System-1 AI, and Avellaneda-Stoikov Market Making

An architectural and quantitative breakdown of Roan's (@RohOnChain) HFT framework: why conventional LLMs fail at high-frequency trading, how TypeSafe AI's Jev achieves calibrated 81ms typed decisions for $0.042/1M tokens, the 8-step system blueprint from L2 orderbook snapshots to Avellaneda-Stoikov pricing, and the two-tier agent symphony pairing Claude Opus 5.5 with Jev.

#Algorithmic Trading#AI Agents#HFT#Jev#Quant Finance#Systems Architecture#Market Making#DevOps
Sub-100ms High-Frequency Trading: Building on Jev, System-1 AI, and Avellaneda-Stoikov Market Making

In algorithmic trading, latency is not merely an engineering metric—it is the direct determinant of market survival.

For the past two years, quant developers attempted to bolt Large Language Models (like GPT-4o or Claude 3.5 Sonnet) onto trading strategies. Every attempt ran straight into a mathematical brick wall: an LLM takes 3 to 15 seconds to reason about an order book.

By the time a conversational model outputs its verbose explanation of order flow imbalance, the Level 2 book has transitioned forty times, market makers have cancelled their quotes, and high-frequency arbitrageurs have executed three blocks ahead of you.

Recently, crypto quant researcher Roan (@RohOnChain) published a comprehensive architectural breakdown demonstrating how to build a real-time, sub-100ms High-Frequency Trading (HFT) system using Jev—a breakthrough model from TypeSafe AI (founded by Diogo Almeida, co-inventor of ChatGPT and InstructGPT at OpenAI).

Instead of producing conversational text, Jev returns calibrated, typed decisions in ~81 milliseconds at $0.042 per million input tokens, with output tokens 100% free.

Here is an architectural autopsy of how this sub-100ms trading engine operates, how it separates deterministic mathematics from model judgment, and how to implement the 8-step pipeline in production.


1. The Core Paradigm Shift: System 1 Reflexes vs. System 2 Reasoning

The fundamental error in applying generative AI to quantitative trading has been confusing Daniel Kahneman’s System 1 (fast, intuitive heuristics) with System 2 (slow, deliberate reasoning):

┌────────────────────────────────────────────────────────────────────────┐
│                        The Quantitative AI Taxonomy                    │
├───────────────────────────────────┬────────────────────────────────────┤
│ Traditional LLMs (System 2)       │ Jev by TypeSafe AI (System 1)      │
├───────────────────────────────────┼────────────────────────────────────┤
│ • Generates verbose markdown/text │ • Zero text generation; typed JSON │
│ • Latency: 3,000ms – 25,000ms     │ • Latency: 70ms – 100ms (p95: 81ms)│
│ • Token cost: $2.50 – $15.00 / 1M │ • Token cost: $0.042 / 1M (Out: $0)│
│ • Misses block confirmation state │ • Fires on every single block (HFT)│
│ • Uncalibrated conversational odds │ • Mathematically calibrated probs  │
└───────────────────────────────────┴────────────────────────────────────┘

In high-frequency environments, software does not need an essay on macroeconomics. It needs instantaneous, calibrated classification:

  • Is this order book toxic?
  • Is this flow informed or noise?
  • Should our quotes lean skew-bid or skew-ask?

Jev delivers these judgments within a single block duration (e.g., 300ms on high-throughput networks like Monad, or 100ms on centralized exchange WebSocket ticks).


2. Architectural Blueprint: The 8-Step System Pipeline

Roan’s framework establishes a strict, fault-tolerant division of responsibilities: Deterministic code owns the mathematics and risk vetoes; Jev owns market judgment.

┌────────────────────────────────────────────────────────────────────────┐
│                   Step 1: Ingestion & Causal Snapshot                  │
│       WebSocket L2 Order Book ──> Compact State Engine (< 400 tok)     │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                   Step 2: Jev 6-Question Battery (81ms)                │
│  Single HTTP/gRPC call evaluates:                                      │
│  1. Regime • 2. Direction • 3. Toxic Flow • 4. Depth • 5. Quote • 6. Inv│
└───────────────────────────────────┬────────────────────────────────────┘
                                    │
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                   Step 3: Deterministic Pricing Engine                 │
│         Avellaneda-Stoikov Reservation Price & Optimal Spread          │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                   Step 4: Kelly Sizing & Execution Veto                │
│      RLCD Calibrated Probabilities ──> Fractional Kelly Sizing         │
│      Safety Checks: Latency > 150ms? Max Drawdown? ──> CANCEL / FLAT   │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │
                                    ▼
┌────────────────────────────────────────────────────────────────────────┐
│                   Step 5: Post-Only Limit Order Dispatch               │
│               Posted 1 Tick Inside the Touch (Sub-100ms Loop)          │
└────────────────────────────────────────────────────────────────────────┘

The 8 Architectural Phases Explained:

Phase 1: The Strict Division of Labor

  • Deterministic Code: Computes order book depth deltas, Volume-Synchronized Probability of Toxicity (VPIN), Order Flow Imbalance (OFI), Avellaneda-Stoikov reservation prices, and hard risk limits.
  • Jev: Ingests the normalized state and evaluates contextual market patterns.

Phase 2: The Compact Causal Snapshot (< 400 Tokens)

Raw L2 feeds overwhelm token budgets. The state engine compacts the top 5 levels of bids and asks, recent trade velocity, micro-price spread, and 10-second volume trends into a dense, nanosecond-timestamped JSON payload strictly under 400 tokens.

Phase 3: The 6-Question Battery in Parallel

Rather than making sequential model calls, the engine fires a single payload that queries six interdependent dimensions simultaneously:

  1. Market Regime: Trending, Mean-Reverting, or Volatile Chop?
  2. Directional Bias: Up, Down, or Neutral?
  3. Toxic Order Flow: Is incoming flow institutional/informed or passive retail?
  4. Liquidity Depth Health: Is book depth resilient or brittle?
  5. Quote Viability: Is the environment safe to quote bid/ask spreads?
  6. Inventory Pressure: Does inventory skew warrant immediate rebalancing?

Phase 4: Calibrated Probabilities (RLCD)

Jev is trained via Reinforcement Learning from Calibrated Data (RLCD). Unlike typical LLMs that express 99% confidence on 55% true likelihoods, Jev’s output probabilities exhibit minimal Expected Calibration Error (ECE). An 80% confidence prediction corresponds to an 80% historical win-rate, allowing mathematical formulas like the Kelly Criterion to calculate position sizing directly from model outputs.

Phase 5: Avellaneda-Stoikov Optimal Market Making

The deterministic engine applies the classic Avellaneda-Stoikov equations to compute the reservation price $r(s, q, t)$:

$$r(s, q, t) = s - q \gamma \sigma^2 (T - t)$$

Where:

  • $s$ = Mid price
  • $q$ = Current inventory position
  • $\gamma$ = Risk aversion parameter
  • $\sigma$ = Volatility
  • $(T - t)$ = Time horizon

Jev adjusts the optimal spread based on its Toxic Flow assessment: if toxic flow probability exceeds 65%, the spread widens automatically to prevent adverse selection.

Phase 6: The Fallback Ladder & Absolute Risk Vetoes

HFT code must fail closed:

  • Latency Veto: If the Jev response takes longer than 150ms, the quote is discarded and the system defaults to HOLD.
  • Drawdown Circuit Breakers: If intraday loss crosses 1.5%, all open limit orders are cancelled immediately, inventory is flattened via passive post-only execution, and the trading loop terminates.

Phase 7: Walk-Forward Backtesting Baselines

The system is backtested against four standard baselines:

  1. Buy and Hold.
  2. Fixed-grid quoting.
  3. Plain vanilla Avellaneda-Stoikov without AI.
  4. Jev-augmented dynamic quoting.

Phase 8: Brier Score Calibration Verification

Every live decision’s predicted probability is logged against realized price action over the subsequent 5, 10, and 30 blocks to ensure Brier score stability.


3. The Two-Tier Symphony: Claude Opus 5.5 + Jev

The ultimate architectural insight of modern AI trading systems is combining Macro Strategy with Micro Reflexes:

[ Tier 1: System 2 Strategic Quant PM (Every Midnight) ]
Claude Opus 5.5 / Claude Code
  • Analyzes 24h trade fills and slippage logs
  • Re-calibrates Avellaneda-Stoikov volatility (γ, σ)
  • Optimizes feature extraction code & ships git commits
                              │
                              ▼ (Deploys Updated Parameters)
[ Tier 2: System 1 Execution Reflex (Every 100ms, 24/7) ]
TypeSafe AI Jev
  • Ingests 400-token L2 causal snapshot
  • Answers 6-question battery in 81ms
  • Dispatches post-only quotes inside the spread
  • Overnight (Opus 5.5 / Claude Code): Acts as the head of quantitative research. It reviews the day’s PnL, analyzes execution slippage, runs parameter sweep regressions, and refactors trading bot code autonomously.
  • Intraday (Jev): Acts as the tireless execution desk on the floor, reacting to every block within 81ms with zero hesitation and negligible token overhead.

4. Implementation Snapshot: The Jev Decision Loop

import time
import requests

def evaluate_market_tick(l2_snapshot: dict) -> dict:
    start_time = time.perf_counter()
    
    # 1. Prepare compact causal payload (< 400 tokens)
    payload = {
        "market": "ETH-USDC",
        "snapshot": l2_snapshot,
        "questions": [
            "regime", "direction", "toxic_flow",
            "liquidity_health", "should_quote", "inventory_bias"
        ]
    }
    
    # 2. Fire high-speed inference call to Jev
    try:
        response = requests.post(
            "https://api.typesafe.ai/v1/jev/decide",
            json=payload,
            timeout=0.150  # Hard 150ms timeout veto
        )
        latency_ms = (time.perf_counter() - start_time) * 1000
        
        if response.status_code == 200:
            decision = response.json()
            decision["latency_ms"] = latency_ms
            return decision
    except requests.Timeout:
        # Fallback Ladder: abort quote if latency budget is violated
        return {"action": "HOLD", "reason": "LATENCY_VETO"}

    return {"action": "HOLD", "reason": "API_ERROR"}

5. Architectural Summary

Dimension Specification
Model Engine Jev (TypeSafe AI) — Specialized System-1 Classifier
Inference Latency 70ms – 100ms (Average: 81ms)
Economics $0.042 / 1M input tokens; output tokens free
Payload Size Dense causal snapshot under 400 tokens
Execution Loop Block-by-block (fires every 100ms – 300ms)
Safety Guardrails 150ms timeout veto, hard drawdown killswitches, post-only orders

The Quant Takeaway:

The era of trying to trade financial markets with conversational LLM chat completions is over.

By adopting System-1 models like Jev for micro-second market reflexes and frontier reasoning models like Claude Opus for macro-strategy governance, quantitative systems architects can build algorithmic pipelines that achieve superhuman reaction speeds with institutional risk discipline.

Fouad Salkini

Written by Fouad Salkini (فؤاد سلقيني)

General Manager & Tech Lead at Tripnologies and Sync Studios. Systems Architect focusing on AI coding agents, DevOps, and quantitative systems.