← All Automations AGENTIC TRADING SYSTEM

Autonomous AI Trading System

Six phases, fully autonomous — Claude Sonnet generates signals, an execution engine validates and places real paper trades on Alpaca, and a circuit breaker plus backtester make sure nothing goes sideways.

WHAT IT DOES

Signal to trade. Zero clicks.

  • Claude Sonnet analyzes market data for each ticker and produces a structured Buy, Hold, or Underweight signal with a confidence score and written rationale — no hardcoded rules
  • The execution engine validates every signal through five risk gates before placing a single Alpaca market-buy order: market hours, available funds, position cap, and correlation limits
  • A 6-hour cron monitors every open position and places a market-sell automatically when the +10% profit target or −5% stop-loss threshold is crossed
  • A circuit breaker reads portfolio equity at day-open and halts all new buys the moment it drops more than 10% — protecting against runaway drawdowns
  • Every weekday evening, a digest fires via Resend email and Telegram with signal count, current P&L, and realized gains from the day
HOW IT WORKS

Six phases, one system.

  1. Phase 1 — Signal Generation

    TradingAgents runs Claude Sonnet in parallel across multiple tickers. Each agent receives recent price data and produces a structured signal: Buy, Hold, or Underweight — with a 0–100 confidence score and a written rationale stored to Supabase.

  2. Phase 2 — Execution Engine

    Buy signals pass through five sequential risk gates: market hours check, available funds check, per-ticker position cap, portfolio correlation threshold, and circuit breaker status. Any failed gate rejects the trade with a logged reason. Approved signals become real Alpaca paper market-buy orders.

  3. Phase 3 — Exit Monitoring

    A 6-hour cron polls every open position. If current price is ≥ +10% above entry (profit target) or ≤ −5% below entry (stop-loss), the engine places a market-sell on Alpaca and writes the exit price, time, status, and realized P&L back to Supabase.

  4. Phase 4 — Daily Digest

    A weekday cron fires at 9PM UTC. It reads the day's signals, current positions, and any realized P&L from Supabase, then sends a structured summary via Resend email and a Telegram bot message. One concise alert per day — no noise.

  5. Phase 5 — Circuit Breaker

    At the start of each UTC day, the system reads portfolio equity and stores it as the day-open baseline in Supabase. Every time the execution engine is invoked, it checks whether current equity has fallen more than 10% below that baseline. If so, all new buys are blocked for the rest of the day — the circuit breaker fails open, so the system keeps running but stops spending.

  6. Phase 6 — Execution-Logic Backtester

    An on-demand POST /backtest endpoint runs the real position-sizing and exit functions against 2 years of OHLCV data using deterministic SMA-crossover signals as a test harness. Reports return, Sharpe ratio, max drawdown, and win rate vs. buy-and-hold — validating execution logic without burning AI credits.

WATCH IT RUN

See the full system live.

Full walkthrough — signal generation, trade execution, exit logic, circuit breaker, backtester, and the live dashboard. All six phases running for real.

Autonomous Trading Dashboard — overview page showing signals, open positions, and confidence scores
▶ Watch on YouTube View Live Dashboard ↓ GitHub
WHAT'S LIVE

Everything is deployed.

  1. 7 API endpoints on Render

    /run · /poll-orders · /daily-digest · /breaker-status · /accuracy-report · /backtest · /health. Python 3.11.9, pinned.

  2. 3 scheduled cron jobs

    Weekly signal run (Monday 9AM UTC) · 6-hourly exit polling · weekday daily digest (9PM UTC). All managed on Render's native cron scheduler.

  3. 5-page Next.js dashboard on Vercel

    Overview · Signals · Positions (live Alpaca prices) · History · Performance (Chart.js P&L chart). Password-gated, reads Supabase server-side. RLS enabled — anon role denied.

  4. 101 passing tests

    TDD'd across all six phases — signal generation, execution, exit logic, circuit breaker, accuracy reporting, and backtester. Run under Python 3.11 in CI.

WANT TO BUILD WITH AI AGENTS?

Let's find what to automate.

All of it's open source.

See the Code →