Skip to content

๐Ÿ† Top 3 Winner @ NVIDIA AI HACKATHON๐Ÿ’กStop Coding, Start Backtesting. The open-source AI Agent platform that turns your ideas into quant analysis.

License

Notifications You must be signed in to change notification settings

nlpquant/AgentQuant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

97 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

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.0 Node.js Python Next.js TypeScript


๐ŸŽฏ 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

Component Technology Purpose
Frontend Next.js 15, React 19, TypeScript Modern web interface with streaming UI
AI Agent LangChain, NVIDIA NAT, Python 3.12 Natural language processing and tool orchestration
Tooling Service FastAPI, MCP Protocol Unified API for market data and execution
Execution Kubernetes, Docker Isolated backtesting environments
Data Store Redis 7 High-performance caching and state management
Charts Lightweight Charts, Recharts Professional financial visualizations
Styling Tailwind CSS, Radix UI Modern, 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

Requirement Version Notes
Node.js 18+ With pnpm package manager
Python 3.12+ With uv package manager
Docker Latest & Docker Compose
Kubernetes Latest For code execution sandbox
Redis 7+ (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 variables
cd 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

Service URL Description
Web Application http://localhost:3000 Main user interface
Agent API http://localhost:8000/docs AI Agent API documentation
Tooling Service http://localhost:8080/docs MCP Server API documentation
Redis Insight http://localhost:5540 Database visualization (dev only)
MCP Inspector http://localhost:6274 Tool 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 Application
cd apps/web && pnpm dev

# Tooling Service
cd apps/mcp-server && uv run uvicorn mcp_server.main:api --reload --port 8080

# AI Agent
cd apps/agent && uv run nat serve --config_file configs/config.yaml

๐Ÿ”ง Adding New Features

Feature Type Location Description
Technical Indicators apps/mcp-server/mcp_server/ Add new trading indicators
UI Components apps/web/components/ Create React components
Agent Tools apps/agent/src/agent/ Extend AI capabilities
API Endpoints apps/mcp-server/mcp_server/ Add new API routes

๐Ÿš€ Deployment

Production Environments

Environment Use Case Description
Docker Compose Development & Production Single-server deployment for all use cases
Kind Cluster Development Local Kubernetes cluster for testing

Environment Configuration

Variable Description Required
LLM_GENERIC_MODEL_NAME Model name for general tasks โœ…
LLM_CODER_MODEL_NAME Model name for code generation โœ…
LLM_GENERIC_MODEL_API_ENDPOINT API endpoint for generic model โœ…
LLM_CODER_MODEL_API_ENDPOINT API endpoint for coder model โœ…
LLM_GENERIC_MODEL_API_KEY API key for generic model โœ…
LLM_CODER_MODEL_API_KEY API key for coder model โœ…
REDIS_URL Redis connection string โœ…
K8S_CONFIG_FILE Kubernetes config path Optional

๐Ÿ“š API Reference

Core Endpoints

Endpoint Method Description
/api/chat POST Submit strategy requests
/api/data/[storageKey] GET Retrieve market data
/api/result/[taskId] GET Get backtest results
/health GET Service health check

MCP Tools

Tool Description
task_register Register new strategy tasks
quick_preview Preview strategy parameters
yh_query_save Fetch and cache market data
code_generator Generate trading strategy code
code_executor Execute 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

Website โ€ข GitHub โ€ข Documentation

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

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •