TK. Talal Khawaja, home Résumé

Case study · 2026 · Hackathon

ThesisCircuit

Paper-only options research agents: three strategies compete, a critic objects, and a fail-closed risk governor has the final say. NO TRADE is a first-class, audited result.

Alpaca AI Trading Agents Hackathon · lablab.ai · 4 Sep 2026

TFIG. 01 — SYSTEM SKETCHGENERATED FROM STACK · NOT A SCREENSHOTTPYTHONFASTAPIALPACA-PYNEXT.JSDOCKERRAILWAY
Fig. — generated system sketch from the project’s stack. Not a product screenshot.

Overview

ThesisCircuit is an autonomous options research and paper-execution system. We built it as team teqprotech for the Alpaca AI Trading Agents Hackathon on lablab.ai and submitted it on 4 September 2026. Its line is "AI strategies compete. Risk decides. Sometimes the best trade is no trade." It is paper trading only. The only broker host it accepts is Alpaca's paper endpoint, and live trading was never created.

Problem

Most trading-agent demos are built to produce a trade. We wanted one that could defend a decision, including the decision not to trade. That meant keeping research, risk approval, broker intent and execution authority separate, so no agent could talk its way around a rejection. It also meant the system had to survive the unglamorous failures: a timeout mid-submission, a restart, two workers claiming the same job.

How it works

Each cycle starts from current Alpaca market, account and options data. Three deterministic agents read the same snapshot. Trend looks for directional continuation, Range looks for mean reversion, and Defensive prefers to preserve capital when the evidence is weak. Each emits a typed thesis with its rationale, confidence, data timestamps, invalidation conditions and a bounded-loss estimate. A decision council compares the theses, and a critic looks for stale evidence, disagreement, liquidity problems and hidden assumptions.

The deterministic risk governor then checks paper mode, endpoint safety, data freshness, liquidity, buying power, bounded premium loss, conflicts, idempotency and session budgets. A rejection becomes an audited NO TRADE. An approval becomes a durable order intent in Supabase that exactly one worker can claim. If a submission times out, the system reconciles by client_order_id before it retries anything. Execution sessions expire on their own and carry separate budgets for opening, closing and total orders.

Rejected but well-formed proposals are kept as shadow records. They are never shown as broker activity, and a documented rule marks each one against later quotes without letting duplicate cycles inflate the sample. The backend is FastAPI on the official alpaca-py SDK, hosted on Railway. The dashboard is a Next.js app on Vercel.

Key decisions and trade-offs

  • Language is kept apart from authority. Agent consensus can create a proposal but cannot authorise an order.
  • Conservative accounting. An order in an UNKNOWN state still consumes budget, and terminal outcomes force the execution flags off.
  • One real proof, then stop. On 2 September 2026 the full pipeline placed a single deliberately small order in the dedicated paper account: one SPY call contract, filled at the limit or better. No second or closing order was submitted. Production now rests with execution and autonomous trading disabled. Bounded autonomous activation was verified synthetically with zero broker calls, and autonomous broker execution was not activated.
  • Clear labels. The dashboard labels paper-account state as actual Alpaca PAPER results. The project's disclosure says these are simulated, hypothetical results and not investment advice.

The project documents its limits too. Historical options paths and exact-horizon quote retrieval are not implemented, so the shadow analysis is not a backtest.

Problem

Most trading-agent demos optimise for producing a trade. A credible agent also has to explain why it refused one, and it has to stay safe through retries, restarts and uncertain broker responses. Persuasive model output must never be able to override a risk rejection.

Approach

Three deterministic strategy agents (Trend, Range, Defensive) read the same live Alpaca snapshot and emit typed theses. A decision council compares them, a critic hunts for stale data and hidden assumptions, and a deterministic risk governor approves or vetoes. Approved ideas become durable order intents, and orders go only to Alpaca's paper endpoint, inside expiring, budgeted sessions. Every step is stored as an auditable event.

My contribution

Team member (teqprotech).

Team teqprotech. Individual credits are being confirmed.

Architecture

01Python02FastAPI03alpaca-py04Next.js05Docker06Railway07Vercel
Diagram — the recorded stack, in project-record order. A sketch, not a screenshot or a data flow.

The detailed architecture for ThesisCircuit hasn’t been documented yet, so this sketch only lists the technologies on the project record. Nothing here is guessed.

Features

  • Strategy arena: Trend, Range and Defensive agents emitting typed theses

  • Critic that challenges the winning thesis

  • Fail-closed risk governor that no agent can override

  • Shadow records for rejected trades, kept apart from real broker activity

  • Durable order intents, atomic claims and reconciliation by client_order_id before any retry

  • Bounded execution sessions with expiry and order budgets

  • Paper-only by construction: live configuration fails closed

Stack

Shipped on lablab.ai, GitHub and Vercel.

Outcome

Submitted to Alpaca AI Trading Agents Hackathon on lablab.ai, 4 Sep 2026.

Result not recorded.

  • One controlled SPY options order (one contract, DAY limit) filled in the dedicated Alpaca PAPER account on 2 Sep 2026. Simulated paper trading, no real funds.
  • Final validation suite: 256 backend tests passing, plus Ruff, frontend typecheck, production build and a paper-safety audit.

Built with Teqprotech · Python, Scraping & Data Automation, AI Agents with Human Approval, API & CRM Integrations.