Case study · Martocci Mayhem

AI Paper Trader

A practice-first trading workspace for U.S. stocks, ETFs and crypto: research, strategy review, order previews, approval gates, risk controls and audit logs, all on paper.

Role
Systems Architect / Developer
Years
2025 — now
Status
Live
AI Paper Trader screenshot

The problem

Traders need to rehearse decisions and automated strategies, and to see exactly what is saved, live or blocked, before any real money is involved.

What it does

  • Three automation modes: off (research only), paper, and live, which is locked.
  • Evaluation rounds preview orders by default and submit at most one per round; the background scheduler runs only after an operator arms it.
  • A strategy runner, broker reconciliation and a permanent order ledger.
  • An AI decision advisor and operator chat, kept behind deterministic risk checks.
  • A public practice demo with a virtual $10,000 portfolio and an alias-only leaderboard.

How it's built

  • An npm workspace: Next.js web app, an execution service, a strategy-runner service and shared broker adapters.
  • PostgreSQL through Prisma on Google Cloud (Cloud Run, Cloud Tasks, Cloud Scheduler, Secret Manager).
  • The Alpaca paper-trading API, with a live crypto stream and a REST fallback; Gemini for the AI advisor.

Engineering decisions

  • Live trading needs two separate server-level switches, and server policy always overrides the saved mode.
  • Stale or missing quotes block new positions, while protective exits still go through; AI recommendations go stale when newer research exists.
  • Low-confidence output, confidence drift and any step toward live trading queue an approval card for a human.
  • Every decision is stored, blocked or not, with a provenance record of which prompt and model produced it.
  • Restarts restore only safe scheduler state and never replay in-flight work; a cost watchdog throttles non-critical scans.
  • Emergency-stop and rollback drills are rehearsed against a test harness.