Research / AI/ML
Building Autonomous Trading Agents with Real-World Intelligence
2025-03-14
Building Autonomous Trading Agents with Real-World Intelligence From news ingestion to trade execution in under 30 seconds — the architecture of Vex Capital --- The promise of AI trading agents is intoxicating: a system that reads the news, understands markets, manages risk, and executes trades — all without human intervention. The reality, for most teams, is a collection of brittle scripts that break the moment market conditions change. At Venym Labs, we built Vex Capital — an autonomous trading agent that has been running continuously, processing thousands of news events and executing trades on Hyperliquid perpetual futures. This document is an unfiltered look at the architecture, the trade-offs, and the lessons learned. The 30-Second Pipeline The north star metric for Vex Capital is simple: from news event to executed trade in under 30 seconds. This is not a theoretical target — it's a measured operational benchmark. This pipeline runs continuously, 24/7, processing events across 12 news categories. System Architecture Layer 1: News Ingestion — The Ingest Pipeline The foundation of any news-driven trading system is reliable, fast data ingestion. Vex Capital's Ingest pipeline is a dedicated service that: Data Sources (12 Categories) Ingestion Pipeline Code Layer 2: Vector Embeddings for Market Event Correlation This is where Vex Capital diverges from conventional trading systems. Instead of extracting features manually (sentiment scores, keyword counts, etc.), we embed the entire article into a high-dimensional vector and use similarity search to find historical analogs. The Embedding Process Why This Works The fundamental insight is that similar news events produce similar market outcomes. Not because of simple word matching, but because: 1. Market participants react to meaning, not words. "SEC rejects Bitcoin ETF" and "US regulator denies crypto fund approval" produce the same market reaction despite no shared keywords. 2. Historical analogs are abundant. In crypto, we've seen thousands of hack announcements, regulation news, ETF decisions, and macro events. For any new event, there are 10-50 genuinely similar historical events. 3. Context matters. The same headline can mean different things in different market regimes. Vector similarity search naturally captures this because recent similar events get higher weight. 4. Cross-category signals emerge. Sometimes a macro headline (CPI data) creates a DeFi-specific opportunity. The embedding space captures these cross-category correlations automatically. Layer 3: Risk Management as Code Risk management in Vex Capital is not a spreadsheet or a dashboard — it's a code layer that sits between signal generation and trade execution. Every trade must pass through the risk manager, and the risk manager can unilaterally reject any trade. Risk Framework Key Risk Parameters | Parameter | Value | Rationale | |-----------|-------|-----------| | Max position size | 10% of portfolio | Limits single-trade impact | | Max daily drawdown | 3% | Hard stop for the day | | Max correlation exposure | 3 correlated positions | Diversification requirement | | Volatility scaling | 0.5x in high-vol regimes | Reduce size when uncertainty is high | | Consecutive loss limit | 5 losses → 24h cooldown | Prevents tilt-driven losses | | News freshness | Reject signals from 15min old articles | Stale signals have no edge | The Circuit Breaker The most important risk feature is the circuit breaker: Layer 4: Execution Engine The execution engine is responsible for translating approved trades into actual orders on Hyperliquid. It handles: Order Management Execution Principles 1. Limit orders first, market orders as fallback. Always try to get price improvement. Only fall back to market orders when the signal urgency justifies the slippage cost. 2. Slippage budgets. Every trade has a maximum acceptable slippage based on signal confidence and market conditions. If the market can't absorb the order within budget, the trade is rejected. 3. IOC (Immediate or Cancel) for limit orders. We don't want orders sitting in the book. If the limit price isn't immediately available, we either fall back to market or skip the trade. 4. Stop-losses are non-negotiable. Every trade has a stop-loss set at order submission time. No exceptions. The Future: Multi-Agent Coordination Vex Capital today is a single agent. The next evolution is multi-agent coordination: Each specialized agent monitors its domain and generates signals. The portfolio coordinator ensures the combined portfolio respects overall risk constraints. This enables: - Domain expertise. Each agent can be fine-tuned for its specific market - Portfolio-level optimization. Risk management considers all positions, not just individual trades - Parallel processing. Agents run independently, scaling linearly The Agent Loop Lessons Learned What Worked 1. Embedding-based similarity search is the single biggest alpha source. It captures nuance that no rule-based