Projects
Agent SystemsFebruary 2, 2026

AI Trading Systems Engineering Prototype

Experimental agentic trading system with xAI Grok analysis, Interactive Brokers connectivity, real-time monitoring, automated execution capability, and decision logs. The case study emphasizes architecture, risk controls, human oversight, and the limits of LLM-generated financial decisions.

Overview

AI Trading Systems Engineering Prototype explores how an LLM-based agent can collect market context, call typed tools, explain a decision, and interact with a broker API. The system has live order-execution capability through Interactive Brokers and includes a dashboard for monitoring positions, decisions, and portfolio state. This is an experimental engineering project, not a claim that an LLM can trade safely or profitably. Model outputs are fallible, market data can be delayed or incomplete, and automated actions can cause financial loss.

Risk Controls and Human Oversight

  • Manual and automated modes are separated in the interface
  • Broker, API, scheduler, and market status are visible before action
  • Stop-loss and take-profit tools exist for explicit risk boundaries
  • Decisions, tool calls, and reflections are persisted for review
  • A human operator remains responsible for credentials, permissions, capital limits, and whether execution is enabled
  • Production use would require stronger pre-trade limits, idempotency, kill switches, reconciliation, independent monitoring, and regulatory review

Key Features

FeatureDescription
AI-Assisted AnalysisGrok analyzes available market context and proposes a decision with reasoning
Real-time DashboardMonitor portfolio value, positions, and P&L with interactive charts
Automated Trading LoopConfigurable intervals (30 min) with manual/auto modes
Decision ReviewThe agent records reflections on past decisions for operator review
Interactive BrokersDirect integration for live order execution

Technical Architecture

Frontend

  • Next.js 14 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first styling with dark/light themes
  • Recharts - Interactive portfolio charts
  • Zustand - State management with persistence
  • React Query - Server state and caching
  • WebSocket - Real-time updates

Backend

  • FastAPI - High-performance async Python API
  • ib_insync - Interactive Brokers SDK for order execution
  • xAI Grok API - AI analysis engine with tool calling
  • SQLite - Local persistence for trades, decisions, reflections
  • APScheduler - Automated trading loop
  • Pydantic - Data validation

AI Agent Features

The Grok agent has access to 12 trading tools:
ToolPurpose
get_stock_price_historyHistorical OHLCV data
get_stock_infoCompany fundamentals
trade_stockExecute buy/sell/close orders
get_portfolio_stateCurrent positions and P&L
search_newsNews and catalyst search
set_stop_loss / set_take_profitRisk management orders

Infrastructure

  • Docker - Containerized deployment
  • Caddy - Reverse proxy with auto-SSL
  • Yahoo Finance - Fallback market data source

Dashboard Features

Portfolio Monitoring

  • Real-time portfolio value with interactive chart (1H/24H/7D/ALL views)
  • Dollar and percentage P&L display
  • Paris and New York timezone clocks

Trading Controls

  • Manual/Auto trading mode toggle
  • Trigger Analysis button for on-demand AI analysis
  • Status indicators (IBKR, API, Scheduler, Market)

Analysis Panel

  • All AI decisions with reasoning (BUY/SELL/KEEP)
  • Chat history with Grok
  • Auto-reflections with lessons learned

Technologies Summary

CategoryTechnologies
FrontendNext.js 14, TypeScript, Tailwind CSS, Recharts, Zustand, React Query
BackendPython 3.11, FastAPI, ib_insync, SQLite, APScheduler
AIxAI Grok API, Tool Calling, Self-Reflection
InfrastructureDocker, Caddy, WebSocket
DataYahoo Finance, Interactive Brokers API