Built with React + TypeScript + Cloudflare Workers β featuring a 15-agent core engine, 18 AI investor personas powered by Fincept Lab, and a CFA-level quantitative analytics suite.
Inspired by https://github.com/SAHU-01/hyperliquid-ai-trader and https://github.com/Fincept-Corporation/FinceptTerminal
Author: Brian (adefebrian.com)
- Overview
- System Architecture
- The 33-Agent System
- Fincept Lab Integration
- Dynamic Margin Engine
- Model Context Protocol (MCP)
- Dashboard Views
- API Endpoints
- Workflow
- Installation & Setup
- Configuration
- Tech Stack
- Project Structure
- License
This project is a production-grade algorithmic trading system for the Hyperliquid DEX. It combines quantitative finance (GARCH volatility, Kelly criterion, VaR risk management) with multi-agent AI consensus to make autonomous trading decisions in paper or live mode.
| Feature | Description |
|---|---|
| 33-Agent Ensemble | 15 core quant agents + 18 AI investor personas (Buffett, Soros, Dalio, etc.) voting together |
| Fincept Lab | CFA-level analytics, 590+ QuantLib endpoints, macro intelligence, risk stress testing |
| Dynamic Margin | Position sizing scales from $12 to 60% of NAV based on composite confidence |
| Fixed Leverage | User-configured leverage (e.g., 20x) stays fixed β never exceeds max_leverage |
| Multi-LLM Support | Alibaba Qwen, OpenAI, Anthropic, DeepSeek, Google Gemini β any OpenAI-compatible API |
| Paper Mode | Full simulation with realistic fills, fees, TWAP/VWAP slicing, and queue modeling |
| Real-time Dashboard | 6 views: Mission Control, Agent Theater, Fincept Lab, MCP Monitor, Trade History, Settings |
| Scalping Presets | One-click intensity modes: LOW, MEDIUM, HIGH, AGGRESSIVE |
| DB Reset from UI | Reset database, portfolio, and settings directly from the dashboard |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND (React + Vite) β
β Mission Control β Agent Theater β Fincept Lab β Settings β ... β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β HTTP / WebSocket
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ
β CLOUDFLARE WORKER (API Gateway) β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β AGENT RUNNER (runCycle) β β
β β β β
β β Tier 1: Signal Layer β β
β β ββ 01 Regime Detection (HMM) β β
β β ββ 02 Alpha Research (IC/IR) β β
β β ββ 03 Sentiment & News (Funding, Fear/Greed) β β
β β ββ 04 Microstructure (OFI, Liquidity) β β
β β ββ 05 Volatility (GARCH) β β
β β ββ 15 Technical Analysis (MTF Confluence) β β
β β β β
β β Fincept Committee (18 AI Personas) β β
β β ββ Buffett, Graham, Lynch, Munger, Soros, Dalio... β β
β β ββ Fed Analyst, Macro Strategist, Credit Analyst β β
β β ββ Geopolitics, Energy, China Watcher β β
β β β β
β β Tier 2: Quant Engine β β
β β ββ 06 Statistics (ADF, Kalman) β β
β β ββ 07 Mathematics (Kelly, Cov Shrinkage) β β
β β ββ 08 Risk Management (VaR, VETO Power) β β
β β ββ 09 Portfolio Construction (Fractional Kelly) β β
β β β β
β β Tier 3: Execution β β
β β ββ 10 Execution (TWAP/VWAP/Iceberg) β β
β β ββ 11 Paper Simulator (Fill + Queue) β β
β β β β
β β Tier 4: Feedback Loop β β
β β ββ 12 Attribution (Brinson) β β
β β ββ 13 Learning (Online Weight Updates) β β
β β ββ 14 Watchdog (Health Monitor) β β
β β β β
β β βΊ ORCHESTRATOR (Weighted Consensus Voting) β β
β β β composite > threshold? β agreement β₯ min? β TRADE β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββ βββββββββββββββ ββββββββββββββββββββββββββ β
β β D1 Database β β MCP Bridge β β Fincept QuantLib Proxy β β
β β (Settings, β β (6 servers) β β (api.fincept.in) β β
β β Trades, β β β β 590+ endpoints β β
β β Portfolio) β β β β β β
β βββββββββββββββ βββββββββββββββ ββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| # | Agent | Role | Key Algorithm |
|---|---|---|---|
| 01 | Regime Detection | Signal (voting) | Hidden Markov Model, Hurst Exponent |
| 02 | Alpha Research | Signal (voting) | Information Coefficient, Ensemble IC |
| 03 | Sentiment & News | Signal (voting) | Funding Rate z-score, Fear & Greed Index |
| 04 | Microstructure | Signal (voting) | Order Flow Imbalance (OFI), Urgency Score |
| 05 | Volatility | Signal (voting) | GARCH(1,1), Realized vs Implied Vol |
| 06 | Statistics | Quant Support | ADF Test, Kalman Filter, Cointegration |
| 07 | Mathematics | Quant Support | Portfolio Optimization, Covariance Shrinkage |
| 08 | Risk Management | VETO Power | VaR (Historical + Cornish-Fisher), Circuit Breakers |
| 09 | Portfolio Construction | Sizing | Fractional Kelly Criterion, Dynamic TP/SL |
| 10 | Execution | Execution | TWAP, VWAP, Post-Only, Iceberg Strategies |
| 11 | Paper Simulator | Simulation | Realistic Fill Engine, Queue Position, Latency |
| 12 | Attribution | Feedback | Brinson Model (Allocation + Selection + Interaction) |
| 13 | Learning | Feedback | Online EMA Weight Updates, Model Versioning |
| 14 | Watchdog | Monitor | Heartbeat Tracking, Latency Anomaly Detection |
| 15 | Technical Analysis | Signal (voting) | Multi-Timeframe Confluence (6 TFs), 8+ Patterns |
These 18 AI personas are powered by your configured LLM (Qwen, GPT-4, Claude, etc.). They run as a single batched API call every 5 minutes and their votes are injected into the Orchestrator alongside core agents.
| # | Persona | Category | Philosophy |
|---|---|---|---|
| 16 | Warren Buffett | Investor | Value investing, economic moats, margin of safety |
| 17 | Benjamin Graham | Investor | Deep value, net-net, quantitative screens |
| 18 | Peter Lynch | Investor | GARP, tenbaggers, invest in what you know |
| 19 | Charlie Munger | Investor | Mental models, inversion, quality at fair price |
| 20 | George Soros | Trader | Reflexivity, macro, boom-bust cycles |
| 21 | Ray Dalio | Trader | All-weather, risk parity, economic machine |
| 22 | Jim Simons | Trader | Quantitative, statistical arbitrage, patterns |
| 23 | Stanley Druckenmiller | Trader | Top-down macro, concentration, liquidity flows |
| 24 | Seth Klarman | Investor | Margin of safety, capital preservation |
| 25 | Howard Marks | Investor | Market cycles, second-level thinking |
| 26 | Bill Ackman | Trader | Activist, catalyst-driven, event-driven |
| 27 | Cathie Wood | Investor | Disruptive innovation, Wright's Law, S-curves |
| 28 | Fed Analyst | Economic | Monetary policy, interest rates, yield curve |
| 29 | Macro Strategist | Economic | GDP, inflation, employment, global trade |
| 30 | Credit Analyst | Economic | Bond markets, credit spreads, default risk |
| 31 | Geopolitics Analyst | Geopolitics | Political risk, sanctions, trade wars |
| 32 | Energy Analyst | Geopolitics | Oil/gas, OPEC, mining economics |
| 33 | China Watcher | Geopolitics | Chinese economy, PBOC, US-China relations |
How it works: The
FinceptCommitteeAgentsends a single prompt to the LLM asking it to role-play all 18 personas simultaneously. Each persona returns adirection(+1/β1/0),confidence(0β1), andreasoning. Results are cached for 5 minutes and fed into the Orchestrator's weighted voting system.
The Fincept Lab tab in the dashboard provides four sub-panels:
Grid view of all 18 personas with live portfolio context. Click any agent to see their individual analysis using your LLM provider.
REST proxy to api.fincept.in β access 590+ quantitative endpoints:
- Risk: Value at Risk (VaR), Expected Shortfall, GARCH
- Pricing: Black-Scholes, Binomial Trees, Monte Carlo
- Portfolio: Markowitz Optimization, Risk Parity
- Fixed Income: Bond Pricing, Duration, Yield Curves
Aggregated real-time market data:
- Fear & Greed Index
- CoinGecko crypto pricing
- Portfolio metrics (NAV, PnL, Win Rate)
- Parametric VaR Calculator
- Stress Testing Scenarios
- Drawdown Analysis
Position sizing is confidence-adaptive β the system allocates more capital when agents strongly agree, and less when signals are weak.
Composite Confidence β Margin Allocation
βββββββββββββββββββββββββββββββββββββββ
< 0.30 (Low) β ~10% of NAV ($12 minimum floor)
0.30β0.60 (Medium) β 15β30% of NAV
0.60β0.80 (High) β 30β45% of NAV
> 0.80 (Very High) β 45β60% of NAV (capped)
Formula: marginPct = min(0.60, 0.10 + compositeConfidence Γ 0.625)
Leverage is always fixed at the user-configured value (e.g., 20x). It is hard-clamped to max_leverage as a safety net β the 50x leverage bug has been permanently fixed.
The system uses MCP to decouple data acquisition from strategy logic:
| Server | Purpose | Default URL |
|---|---|---|
| News Sentiment | Real-time crypto news + sentiment | Custom |
| Orderbook Analyzer | L2 book analytics, imbalance | Custom |
| Technical Analyzer | 20+ indicators (RSI, EMA, BB) | technical-analyzer-mcp.*.workers.dev |
| Signal Generator | Unified alpha signal aggregation | signal-generator-mcp.*.workers.dev |
| Hyperliquid Trader | Exchange API interface | hyperliquid-trader-mcp.*.workers.dev |
| Performance Tracker | Historical PnL + metrics | performance-tracker-mcp.*.workers.dev |
| Tab | Description |
|---|---|
| Mission Control | Agent consensus bars, open positions, equity curve, risk status, decision log |
| Agent Theater | Full 33-agent grid with confidence, direction, role, and per-agent details |
| Fincept Lab | AI personas, QuantLib explorer, market intelligence, risk analytics |
| MCP Monitor | Server health, latency graphs, ping testing, activity log |
| Trade History | Complete trade log with entry/exit prices, PnL, hold time, regime |
| Settings | Capital, leverage, risk limits, LLM config, scalping presets, DB reset |
| Mode | Leverage | Threshold | Min Agreement | Kelly |
|---|---|---|---|---|
| LOW (Conservative) | 5x | 0.30 | 3 | 0.10 |
| MEDIUM (Balanced) | 10x | 0.20 | 2 | 0.25 |
| HIGH (HF) | 20x | 0.15 | 2 | 0.50 |
| AGGRESSIVE (Max) | 20x | 0.10 | 1 | 1.00 |
| Method | Path | Description |
|---|---|---|
| POST | /system/start |
Start auto-cycling |
| POST | /system/stop |
Stop auto-cycling |
| POST | /system/run-cycle |
Run single trading cycle |
| POST | /system/emergency-halt |
Emergency halt β close all positions |
| GET | /system/status |
System running state |
| Method | Path | Description |
|---|---|---|
| GET/POST | /settings |
Get/save system settings (auto-resets portfolio on capital change) |
| POST | /settings/mode |
Switch paper/live mode |
| POST | /settings/agent |
Toggle/weight individual agents |
| GET/POST | /settings/llm |
LLM configuration (API key masked on GET) |
| POST | /settings/llm/test |
Test LLM connection |
| POST | /settings/reset |
Full database reset |
| Method | Path | Description |
|---|---|---|
| GET | /positions |
Open positions (with live mark-to-market) |
| POST | /positions/:id/close |
Close specific position |
| POST | /paper/open |
Manually open paper position |
| GET | /paper/pnl |
NAV, cash, realized PnL, win rate |
| GET | /paper/history |
Trade history (last 100) |
| POST | /paper/reset |
Reset portfolio to initial capital |
| Method | Path | Description |
|---|---|---|
| GET | /agents/status |
All agent outputs, reasoning, decision |
| GET | /equity-curve |
Equity curve data (last 500 points) |
| GET | /decision-log |
Orchestrator decision history |
| GET | /risk/current |
Current risk metrics |
| GET | /performance |
Sharpe, Sortino, win rate, profit factor |
| Method | Path | Description |
|---|---|---|
| POST | /fincept/quantlib/* |
Proxy to QuantLib API (590+ endpoints) |
| GET | /fincept/quantlib/* |
Proxy to QuantLib API (GET) |
| POST | /fincept/agents/analyze |
Single agent persona analysis |
| GET | /fincept/market-intel |
Aggregated market intelligence |
| Method | Path | Description |
|---|---|---|
| GET | /mcp/status |
All MCP server statuses |
| POST | /mcp/ping |
Ping specific MCP server |
| GET | /mcp/log |
MCP activity log |
1. MARKET SNAPSHOT
ββ MCP Bridge fetches Price, Orderbook, News, Volatility data
2. AGENT ANALYSIS (Every Cycle)
ββ 6 Core Voting Agents compute signals (instant, pure math)
ββ 18 Fincept Personas provide AI opinions (cached 5 min)
ββ Quant Engine calculates risk, sizing, Kelly
ββ Execution Agent selects optimal strategy
3. ORCHESTRATOR CONSENSUS
ββ Weighted sum of all agent signals
ββ composite_confidence > threshold? β
ββ agreement_count β₯ min_agents? β
ββ Risk Agent VETO check? β
ββ TA Price Action VETO check? β
ββ Regime + MTF gates passed? β β TRADE APPROVED
4. DYNAMIC MARGIN SIZING
ββ $12 min ββββ scales by confidence ββββ 60% NAV max
5. EXECUTION
ββ Paper Mode: Realistic fill simulation
ββ Live Mode: Hyperliquid API execution
6. FEEDBACK & LEARNING
ββ Attribution decomposes PnL sources
ββ Learning Agent updates signal weights
ββ Watchdog monitors system health
- Node.js v18+
- Cloudflare Wrangler (global or npx)
- An LLM API key (Alibaba Qwen recommended β cheapest for high quality)
git clone https://github.com/Adefebrian/Quantrader.git
cd Quantrader
npm installcd workers/api-gateway
npm install
# Initialize D1 Database
npx wrangler d1 create trading-db
# Local development
npx wrangler dev
# Production deploy
npx wrangler deploycd frontend
npm install
# Local development (opens on http://localhost:5173)
npm run dev
# Production build
npm run build- Open the dashboard β Settings tab
- Select your LLM provider (recommended: Qwen via Alibaba DashScope)
- Enter your API key
- Click Test Connection β Save
Recommended LLM for cost-efficiency:
Provider: Qwen (Alibaba DashScope)
Model: qwen-max-2025-01-25
Base URL: https://dashscope-intl.aliyuncs.com/compatible-mode/v1
All configurations are managed via the Settings tab:
- Initial Capital ($): Starting NAV for paper trading (auto-resets portfolio on change)
- Default Leverage: Fixed leverage for all positions (hard-clamped to max)
- Consensus Threshold: Minimum composite score to approve a trade
- Min Agent Agreement: How many agents must agree on direction
- Kelly Fraction: Position sizing aggressiveness (0.1 = conservative, 1.0 = full Kelly)
- DD Daily Halt/Stop: Drawdown thresholds for pausing/stopping
- DD Total: Maximum total drawdown before emergency halt
- VaR 95% Daily: Value at Risk limit
- Max Single/Corr Exposure: Position concentration limits
- Max Margin Utilization: How much of NAV can be used as margin
Supports any OpenAI-compatible API:
- Alibaba Qwen (DashScope)
- OpenAI (GPT-4o, GPT-4o-mini)
- Anthropic (Claude Sonnet)
- Google (Gemini Flash)
- DeepSeek Chat
- Custom endpoints (Ollama, OpenRouter, etc.)
- Reset Settings: Restore all settings to defaults
- Reset Portfolio: Clear all positions and trade history
- Full DB Reset: Nuclear option β wipes everything
| Layer | Technology |
|---|---|
| Frontend | React 18 + TypeScript + Vite |
| Styling | Vanilla CSS (dark theme, glassmorphism) |
| Backend | Cloudflare Workers (edge computing) |
| Database | Cloudflare D1 (SQLite at the edge) |
| Real-time | WebSocket (dashboard events) |
| AI/LLM | Multi-provider (Qwen, OpenAI, Anthropic, Gemini, DeepSeek) |
| Quant API | Fincept QuantLib (api.fincept.in) |
| Data | MCP servers, Hyperliquid API, CoinGecko, Fear & Greed Index |
hyperliquid-ai-trader/
βββ frontend/ # React Dashboard
β βββ src/
β βββ App.tsx # Main app (all 6 views)
β βββ index.css # Design system + dark theme
β βββ main.tsx # Entry point
β
βββ workers/api-gateway/ # Cloudflare Worker Backend
β βββ src/
β βββ index.ts # API Gateway (all endpoints)
β βββ agents/ # 15 Core Agent implementations
β β βββ agent-01-regime.ts
β β βββ agent-02-alpha.ts
β β βββ agent-03-sentiment.ts
β β βββ agent-04-microstructure.ts
β β βββ agent-05-volatility.ts
β β βββ agent-06-statistics.ts
β β βββ agent-07-math.ts
β β βββ agent-08-risk.ts
β β βββ agent-09-portfolio.ts
β β βββ agent-10-execution.ts
β β βββ agent-12-attribution.ts
β β βββ agent-15-technical.ts
β β βββ agent-runner.ts # Cycle orchestration
β β βββ orchestrator.ts # Weighted consensus voting
β β βββ message-bus.ts # Inter-agent messaging
β β βββ types.ts # All type definitions
β βββ fincept/ # Fincept Lab Integration
β β βββ investor-agents.ts # 18 persona definitions
β β βββ fincept-committee.ts # Batched LLM committee agent
β βββ mcp/ # MCP Data Bridge
β β βββ data-bridge.ts # Market snapshot builder
β βββ paper/ # Paper Trading Engine
β β βββ portfolio.ts # Position management + PnL
β βββ utils/ # Math & indicator libraries
β βββ math.ts # Statistical functions
β βββ indicators.ts # Technical indicators
β
βββ mcp-servers/ # MCP Server implementations
βββ migrations/ # D1 database migrations
βββ scripts/ # Utility scripts
βββ FinceptTerminal-main/ # Fincept source (reference)
βββ package.json
This project is licensed under the MIT License β see the LICENSE file for details.
Developed with β€οΈ by Brian (adefebrian.com)