Case study

AI Trading Research & Decision Lab

FinTech · Quantitative Research · AI Automation

Project overview

We built the platform, a local, paper-trading research and decision platform that separates every stage of the trading decision. Its guiding principle is: code calculates, Jev interprets, policy decides, hard risk rules veto, and execution stays controlled.

Pipeline: Market Data → Feature Engine → State Snapshot → Jev → Policy Engine → Hard Risk → Paper Execution → Logging / Calibration

Deterministic state engine: Python computes mid, microprice, spread, order-book imbalance, depth, volatility, drawdown and data age. No arithmetic is left to an AI model.

Jev judgment battery: A compact state is sent to Jev (TypeSafe) with several small, typed questions: market regime, direction, toxic flow, liquidity stress, quote environment and inventory pressure. All vendor-specific details sit in one adapter.

Policy engine: Configurable thresholds turn Jev's answers into an action (QUOTE, WIDEN, PULL or HOLD), with confidence gating for high, medium and low confidence.

Hard risk engine: Deterministic Python rules for position, order size, daily loss, drawdown, stale data, decision latency and exchange health can veto any action and return HOLD, PULL or KILL, even if Jev says otherwise.

Safe by design: The system starts in paper and sandbox mode, live execution is not available from the UI, and a decision that arrives after its deadline is never executed.

Azure GPT-5 research lab: Azure OpenAI GPT-5 turns a strategy idea into a structured research plan (hypothesis, features, rules, costs, failure modes, validation plan). Output is labelled as AI-generated research and has no execution authority.

Local backtesting and calibration logging: CSV datasets can be validated and backtested, and each decision is logged with its outcome so confidence can be checked later.

Business problem

Quant researchers, developers and trading-system operators who want to test AI-assisted trading ideas face a set of practical problems

Language models are often placed too close to execution, even though they are too slow and too unpredictable to act as a trading gate on their own.

Calculations such as spreads, order-book imbalance and volatility are sometimes handed to a model when plain code can compute them exactly.

There is rarely a clear line between what the code calculates, what the AI interprets, what policy decides and what risk rules can veto.

Teams have no safe, local environment to try these ideas without risking real money.

Decisions, risk events and outcomes are not logged in a way that supports later calibration, so confidence in a model is hard to verify.

Non-technical stakeholders cannot see what the system is doing or why it held back a trade.

Technical approach

Backend: Python 3.12, Django 5.2 LTS, Django ORM, Django admin and authentication

Database: PostgreSQL (psycopg 3)

Frontend: Django templates with HTML5, CSS3 and vanilla JavaScript, in a light, responsive design system

AI: Azure OpenAI GPT-5 (Responses API, structured output) for research; Jev / TypeSafe as the bounded decision layer

Exchange Layer: CCXT for market data, order books and sandbox integration, behind a separate exchange adapter

Execution: TradingGateway, ExchangeAdapter and PaperExecutionAdapter interfaces

Storage & Config: Local media storage for datasets and reports; secrets read from a local .env file

Key capabilities

  • Dashboard with system, Jev, Azure GPT-5, exchange, paper / sandbox, position, P&L, drawdown, latency and risk status cards
  • Visual decision pipeline showing each stage's status, last update and latency
  • Market monitor with best bid / ask, spread, imbalance, depth, volatility, and LIVE / STALE data status
  • Deterministic feature and state engine
  • Jev adapter with a six-question judgment battery and friendly handling of missing keys, timeouts and malformed replies
  • Policy engine with configurable thresholds and confidence gating
  • Hard risk engine with a kill switch and a fallback ladder shown in the UI
  • Stale-decision protection, so a late decision is never executed
  • Paper execution adapter, with no calls to live trading endpoints
  • Management command to run the trading loop at a configurable interval
  • Avellaneda-Stoikov-style pricing module for reservation price and half spread
  • AI Research page powered by Azure GPT-5
  • CSV backtesting with data validation, cost and slippage assumptions, and warnings for gaps or duplicates
  • Calibration-ready logging of state, decision, confidence, action and outcome
  • Database models for sessions, market snapshots, decisions, orders, risk events and AI request logs
  • JSON API endpoints, configuration page, first-run onboarding, admin tools and a test suite
  • Setup guides for Windows, Jev, Azure OpenAI and CCXT, plus architecture and risk documentation

Quantified outcomes are not published for this project. Confidential client information, source code and proprietary datasets are deliberately excluded.

Keep exploring

More case studies