Skip to content

Repository files navigation

🚀 AgentQuant

AI-Powered Quantitative Trading Platform

Transform natural language into sophisticated trading strategies with real-time backtesting and interactive visualization

Join Waitlist

License: AGPL-3.0Node.jsPythonNext.jsTypeScript


🎯 Overview

AgentQuant is a cutting-edge AI-assisted quantitative trading platform that revolutionizes how traders and developers approach strategy development. By combining advanced language models with sophisticated tooling infrastructure, it transforms natural language trading ideas into executable, backtestable strategies with comprehensive performance analytics.

AgentQuant Platform Interface

AgentQuant's intuitive interface - "The Flight Simulator for Trading Strategies"

AgentQuant Demo

See AgentQuant in action - from natural language to trading results in seconds!

🚀 Ready to try AgentQuant?Join our waitlist for early access to the platform!

✨ Key Features

  • 🤖 AI-Powered Strategy Generation: Convert natural language into sophisticated trading logic
  • 📊 Real-Time Market Data: Live data feeds with intelligent caching and preprocessing
  • 🔬 Advanced Backtesting: Isolated execution environments with comprehensive metrics
  • 📈 Interactive Visualization: Beautiful charts, KPIs, and trade analysis
  • 🔄 Streaming Progress: Real-time feedback during strategy development
  • 🛠️ Extensible Architecture: Modular design with pluggable components
  • 🚀 Production Ready: Docker-based deployment with Kubernetes support

🏗️ Architecture

System Components

graph TB
subgraph "Frontend Layer"
UI[Web App<br/>Next.js + React]
UI --> |Chat Interface| API[API Routes]
end
subgraph "AI Layer"
AGENT[AI Agent<br/>LangChain + NAT + Qwen]
AGENT --> |Tool Calls| MCP[MCP Server]
end
subgraph "Data & Execution Layer"
MCP --> |Market Data| REDIS[(Redis Cache)]
MCP --> |Code Execution| K8S[Kubernetes<br/>Execution Sandbox]
K8S --> |Results| REDIS
end
subgraph "External Services"
MARKET[Market Data<br/>Yahoo Finance]
LLM[LLM Services<br/>OpenAI/Qwen]
end
API --> AGENT
AGENT --> LLM
MCP --> MARKET
classDef frontend fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff
classDef ai fill:#f093fb,stroke:#f5576c,stroke-width:3px,color:#fff
classDef data fill:#4facfe,stroke:#00f2fe,stroke-width:3px,color:#fff
classDef external fill:#43e97b,stroke:#38f9d7,stroke-width:3px,color:#fff
class UI,API frontend
class AGENT,MCP ai
class REDIS,K8S data
class MARKET,LLM external
Loading

Technology Stack

ComponentTechnologyPurpose
FrontendNext.js 15, React 19, TypeScriptModern web interface with streaming UI
AI AgentLangChain, NVIDIA NAT, Python 3.12Natural language processing and tool orchestration
Tooling ServiceFastAPI, MCP ProtocolUnified API for market data and execution
ExecutionKubernetes, DockerIsolated backtesting environments
Data StoreRedis 7High-performance caching and state management
ChartsLightweight Charts, RechartsProfessional financial visualizations
StylingTailwind CSS, Radix UIModern, accessible design system

End-to-End Sequence (Simplified)

sequenceDiagram
participant User
participant Web as Web
participant Agent as Agent
participant Tools as Tooling Service
participant Store as Data Store
participant Runner as Execution Sandbox
User->>Web: Submit strategy request
Web->>Agent: Send request (streaming)
Agent->>Tools: Register task / preview parameters
Agent->>Tools: Fetch market data (cached)
Agent->>Tools: Generate and run backtest
Tools->>Runner: Execute strategy in isolation
Runner->>Store: Read/write data
Tools-->>Agent: Return metrics and outputs
Agent-->>Web: Summarize results and visuals
Note over User,Web: Frontend Layer
Note over Agent,Tools: AI & Service Layer
Note over Store,Runner: Data & Execution Layer
Loading

🚀 Quick Start

📋 Prerequisites

RequirementVersionNotes
Node.js18+With pnpm package manager
Python3.12+With uv package manager
DockerLatest& Docker Compose
KubernetesLatestFor code execution sandbox
Redis7+(Included in Docker setup)
LLM API Keys-For both generic and coder models

Option 1: Docker Compose (Recommended)

# Clone the repository
git clone https://github.com/nlpquant/AgentQuant.git
cd AgentQuant
# Set up environment variablescd deploy
export LLM_GENERIC_MODEL_NAME='qwen3-plus'export LLM_CODER_MODEL_NAME='qwen3-coder-plus'export LLM_GENERIC_MODEL_API_ENDPOINT='your-api-endpoint'export LLM_CODER_MODEL_API_ENDPOINT='your-api-endpoint'export LLM_GENERIC_MODEL_API_KEY='your-api-key'export LLM_CODER_MODEL_API_KEY='your-api-key'# Start all services
docker-compose up -d
# Check service health
docker-compose ps

Option 2: Local Development

# Install dependencies
pnpm install
# Start Redis
docker run --rm -p 6379:6379 redis:7-alpine
# Start Kubernetes cluster (required for code execution)cd deploy
docker-compose up kind -d
# Wait for cluster to be ready
docker-compose exec kind sh -c "kubectl wait --for=condition=Ready nodes --all --timeout=300s"# Verify cluster is running
docker-compose exec kind sh -c "kubectl get nodes"# Start Tooling Service (in new terminal)cd apps/mcp-server
uv venv --python 3.12 --seed .venv
source .venv/bin/activate
uv sync
uv run uvicorn mcp_server.main:api --reload --port 8080
# Start AI Agent (in new terminal)cd apps/agent
uv venv --python 3.12 --seed .venv
source .venv/bin/activate
uv sync
export LLM_GENERIC_MODEL_API_KEY='your-api-key-here'export LLM_CODER_MODEL_API_KEY='your-api-key-here'
uv run nat serve --config_file configs/config.yaml
# Start Web App (in new terminal)cd apps/web
pnpm dev
# Optional: Start development tools (in new terminal)cd deploy
# Start Redis Insight for database visualization
docker-compose up redis-insight -d
# Start MCP Inspector for tool debugging
docker-compose up mcp-inspector -d

🌐 Access Points

ServiceURLDescription
Web Applicationhttp://localhost:3000Main user interface
Agent APIhttp://localhost:8000/docsAI Agent API documentation
Tooling Servicehttp://localhost:8080/docsMCP Server API documentation
Redis Insighthttp://localhost:5540Database visualization (dev only)
MCP Inspectorhttp://localhost:6274Tool debugging (dev only)

💡 Development Tools: Redis Insight and MCP Inspector are available via Docker Compose for debugging and monitoring during development.


🎮 Usage Examples

✅ Basic Strategy Request

"Create a moving average crossover strategy for AAPL with 20-day and 50-day periods,
backtest it for the last 2 years, and show me the performance metrics"

🚧 Advanced Technical Analysis (In Roadmap)

"Build an RSI mean reversion strategy for SPY with:
- RSI oversold at 30, overbought at 70
- Bollinger Bands for entry confirmation
- 2% stop loss, 4% take profit
- Backtest on 5-minute data for the last 3 months"

🚧 Multi-Asset Strategy (In Roadmap)

"Create a pairs trading strategy between INTC and AMD using:
- 60-day rolling correlation
- Z-score entry/exit signals
- Risk management with position sizing
- Show me the equity curve and drawdown analysis"

📊 Features Deep Dive

🤖 AI Agent Capabilities

  • Natural Language Understanding: Interprets complex trading requirements
  • Multi-Step Planning: Breaks down complex strategies into executable steps
  • Tool Orchestration: Seamlessly coordinates data fetching, analysis, and execution
  • Streaming Feedback: Real-time progress updates during strategy development
  • Error Recovery: Intelligent handling of failures with retry mechanisms

📈 Market Data & Analysis

  • Real-Time Data: Live market feeds via Yahoo Finance API
  • Historical Data: Comprehensive historical datasets with multiple timeframes
  • Technical Indicators: 50+ built-in indicators (RSI, MACD, Bollinger Bands, etc.)
  • Data Caching: Intelligent Redis-based caching for performance
  • Data Validation: Automatic data quality checks and preprocessing

🔬 Backtesting Engine

  • Isolated Execution: Secure, sandboxed code execution environments
  • Multiple Timeframes: Support for tick, minute, hourly, daily data
  • Realistic Simulation: Slippage, commissions, and market impact modeling
  • Performance Metrics: 20+ comprehensive performance indicators
  • Risk Analysis: Drawdown, Sharpe ratio, maximum adverse excursion

📊 Visualization & Analytics

  • Interactive Charts: Professional candlestick charts with technical overlays
  • Performance Dashboards: Real-time KPI monitoring and analysis
  • Trade Analysis: Detailed trade-by-trade breakdown with entry/exit points
  • Signal Visualization: Clear buy/sell signal overlays on price charts
  • Export Capabilities: PDF reports and CSV data export

🛠️ Development

Project Structure

AgentQuant/
├── apps/
│ ├── web/ # Next.js frontend application
│ ├── agent/ # AI agent service (Python)
│ └── mcp-server/ # Tooling service (FastAPI)
├── deploy/ # Docker and Kubernetes configurations
├── assets/ # Static assets (images, demos)
└── LICENSE # AGPL-3.0 license

🛠️ Available Scripts

Monorepo Commands

pnpm build # Build all applications
pnpm dev # Start all services in development mode
pnpm lint # Run linting across all packages
pnpm format # Format code with Prettier
pnpm test# Run test suites

Individual Service Commands

# Web Applicationcd apps/web && pnpm dev
# Tooling Servicecd apps/mcp-server && uv run uvicorn mcp_server.main:api --reload --port 8080
# AI Agentcd apps/agent && uv run nat serve --config_file configs/config.yaml

🔧 Adding New Features

Feature TypeLocationDescription
Technical Indicatorsapps/mcp-server/mcp_server/Add new trading indicators
UI Componentsapps/web/components/Create React components
Agent Toolsapps/agent/src/agent/Extend AI capabilities
API Endpointsapps/mcp-server/mcp_server/Add new API routes

🚀 Deployment

Production Environments

EnvironmentUse CaseDescription
Docker ComposeDevelopment & ProductionSingle-server deployment for all use cases
Kind ClusterDevelopmentLocal Kubernetes cluster for testing

Environment Configuration

VariableDescriptionRequired
LLM_GENERIC_MODEL_NAMEModel name for general tasks
LLM_CODER_MODEL_NAMEModel name for code generation
LLM_GENERIC_MODEL_API_ENDPOINTAPI endpoint for generic model
LLM_CODER_MODEL_API_ENDPOINTAPI endpoint for coder model
LLM_GENERIC_MODEL_API_KEYAPI key for generic model
LLM_CODER_MODEL_API_KEYAPI key for coder model
REDIS_URLRedis connection string
K8S_CONFIG_FILEKubernetes config pathOptional

📚 API Reference

Core Endpoints

EndpointMethodDescription
/api/chatPOSTSubmit strategy requests
/api/data/[storageKey]GETRetrieve market data
/api/result/[taskId]GETGet backtest results
/healthGETService health check

MCP Tools

ToolDescription
task_registerRegister new strategy tasks
quick_previewPreview strategy parameters
yh_query_saveFetch and cache market data
code_generatorGenerate trading strategy code
code_executorExecute backtest code

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run the test suite: pnpm test
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

📄 License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.


🙏 Acknowledgments

  • LangChain for AI orchestration framework
  • NVIDIA NAT for agent infrastructure
  • Alibaba Qwen for performant Large Language Model
  • FastAPI for high-performance API framework
  • Next.js for modern React framework
  • Lightweight Charts for financial visualizations
  • Redis for high-performance caching

📞 Support


Built with ❤️ by the NLPQuant Team

WebsiteGitHubDocumentation

About

🏆 Top 3 Winner @ NVIDIA AI HACKATHON💡Stop Coding, Start Backtesting. The open-source AI Agent platform that turns your ideas into quant analysis.

Topics

Resources

Stars

17 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages