AlphaAirlock: A Multi-Agent Pipeline That Vets Its Own Trading Ideas Before They Touch a Backtest
Summary
AlphaAirlock is an open-source, multi-agent pipeline designed to convert unstructured market commentary into sandbox-backtested, risk-vetted trading strategies for crypto perpetuals and US equities. This system employs a five-stage LLM agent pipeline—Intake, Researcher, Coder, Backtester, and Critic—driven by an explicit state machine. Key guardrails include an AST-whitelisted sandbox for generated factor code, blocking "os", "sys", "subprocess" at the bytecode level, and an 8-second watchdog. It prevents look-ahead bias at both the factor and backtester layers, running against a bundled 2-year synthetic hourly BTC perpetual dataset (17,520 bars) with a 0.07%-per-side cost model. The Critic agent enforces hard numeric thresholds like Sharpe ratio and max drawdown, overriding LLM self-assessments. Live trading is disabled by default, ensuring a fail-closed system. The backend uses FastAPI (Python 3.11+), SQLAlchemy, and SQLite, with a Next.js frontend, and supports LLM routing via Anthropic Claude, OpenRouter, or MiniMax.
Key takeaway
For AI Engineers or MLOps Engineers building agentic systems for high-stakes domains like finance, you should prioritize robust guardrails and adversarial review. This architecture demonstrates how to prevent common failure modes, such as unreviewed code execution or look-ahead bias in simulations, by implementing explicit state machines, sandboxing, and a critical review agent with veto power. Consider adopting a fail-closed default and multi-layered validation to enhance system trustworthiness and mitigate risks.
Key insights
A multi-agent LLM pipeline can rigorously vet trading strategies through sandboxing, adversarial review, and explicit guardrails.
Principles
- Implement explicit state machines for agent workflows.
- Enforce hard numeric thresholds for critical decisions.
- Default to fail-closed for high-risk operations.
Method
The pipeline processes market commentary through Intake, Researcher, Coder, Backtester, and Critic agents, using a one-retry loop and an explicit state machine to approve or reject strategies.
In practice
- Use AST parsing to sandbox LLM-generated code.
- Apply multi-layer look-ahead bias prevention in backtesting.
- Integrate a "Critic" agent with veto power based on metrics.
Topics
- Multi-Agent Systems
- LLM Guardrails
- Algorithmic Trading
- Backtesting
- Financial Risk Management
- Code Sandboxing
Code references
Best for: AI Engineer, MLOps Engineer, AI Architect
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning on Medium.