利用WorldQuant API来生成α信号,以及我充满希望的α表达.
WorldQuant Alpha Generator
This project is a collection of scripts that generate and submit alphas to the WorldQuant platform.
Recommended Approach: Naive-Ollama
For the best performance and user experience, we recommend using the Naive-Ollama Alpha Generator which features:
- 3-5x faster alpha generation with local Ollama LLM
- ️ GPU acceleration for optimal performance
- Real-time web dashboard for monitoring and control
- Fully automated 24/7 operation
- Local processing - no external API costs or privacy concerns
- Docker support for easy deployment
- Advanced orchestration with intelligent scheduling
Quick Start:
cd naive-ollama
# Setup credentials in credential.txt
docker-compose -f docker-compose.gpu.yml up -d
# Access dashboard at http://localhost:5000
__ __ .__ .___ __ .__
/ \ / \___________| | __| _/________ _______ _____/ |_ _____ |__| ____ ___________
\ \/\/ / _ \_ __ \ | / __ |/ ____/ | \__ \ / \ __\ / \| |/ \_/ __ \_ __ \
\ ( ) | \/ |__/ /_/ __|
\/ \/ |__| \/ \/ \/ \/ \/
Discord: https://discord.gg/3B2TmHQw
Usage Tutorial(WIP) on the web version: https://www.youtube.com/watch?v=xwr9atsulSA
Further usage tutorial on the local ollama version: https://www.youtube.com/watch?v=EAeujBRrKiI
Rust Alpha Generator
This is a Rust implementation of the alpha generator.
Installation
cargo build --release
Usage
cargo run --release
Python Alpha Generator
This is a Python implementation of the alpha generator.
Generation Two: Advanced Alpha Mining System
Generation Two is a self-optimizing, modular alpha mining system with advanced features:
- Self-Optimization: Adaptive parameter tuning based on performance
- Genetic Evolution: Genetic algorithm-based alpha evolution
- ⚡ Continuous Mining: Automated 24/7 alpha discovery with error correction
- Cyberpunk GUI: Modern graphical interface for system control
- Smart Ollama Integration: Local LLM with automatic fallback
- ✅ Template Validation: Self-correcting AST with error learning
- Expression Compiler: Multi-stage compilation pipeline
- Quality Monitoring: Performance tracking and degradation detection
Quick Start:
cd generation_two
pip install -r requirements.txt
python gui/run_gui.py [credential_path]
Documentation: See generation_two/DOCUMENTATION.md for complete documentation.
Key Features:
- Modular architecture with separated concerns
- Concurrent simulation execution
- Automated error correction and template fixing
- Field placeholder replacement (DATA_FIELD1 → actual fields)
- Infinite retry for critical errors
- Real-time progress monitoring
- Build support for Windows (EXE), Linux (DEB), macOS (DMG)
Introduction: Difference between Pre-Consultant and Consultant
- Pre-Consultant has maximum 5 concurrent simulations
- Pre-Consultant has fewer operators and data fields options
Agent N8N
Incoming... lol
Naive-Ollama Alpha Generator (Recommended)
A sophisticated alpha factor generation system that uses Ollama with financial language models to generate, test, and submit alpha factors to WorldQuant Brain. This system replaces the previous Kimi interface with a local Ollama-based solution for better performance and control.
Key Features
- Local LLM Integration: Uses Ollama with llama3.2:3b or llama2:7b models
- GPU Acceleration: Full NVIDIA GPU support for faster inference
- Web Dashboard: Real-time monitoring and control interface
- Automated Orchestration: Continuous alpha generation, mining, and submission
- WorldQuant Brain Integration: Direct API integration for testing and submission
- Docker Support: Easy deployment with Docker and Docker Compose
- Daily Rate Limiting: Ensures compliance with WorldQuant submission limits
️ Architecture
…
Quick Start
1. Setup Credentials
Create naive-ollama/credential.txt with your WorldQuant Brain credentials:
["[email protected]", "your_password"]
2. Start with GPU Support (Recommended)
cd naive-ollama
# Start the complete system with GPU acceleration
docker-compose -f docker-compose.gpu.yml up -d
# Or use the convenience script
start_gpu.bat
3. Access the Web Dashboard
Open your browser and navigate to:
Web Dashboard Features
The web dashboard provides real-time monitoring and control:
Status Monitoring
- GPU Status: Memory usage, utilization, temperature
- Ollama Status: Model loading, API connectivity
- Orchestrator Status: Generation activity, mining schedule
- WorldQuant Status: API connectivity, authentication
- Statistics: Generated alphas, success rates, 24h metrics
Manual Controls
- Generate Alpha: Trigger single alpha generation
- Trigger Mining: Run alpha expression mining
- Trigger Submission: Submit successful alphas
- Refresh Status: Update all metrics
Real-time Logs
- Alpha Generator Logs: Filtered logs showing alpha generation activity
- System Logs: Complete system activity
- Recent Activity: Timeline of recent events
Workflow
1. Alpha Generation
- Continuous Mode: Generates alphas every 6 hours
- Batch Processing: Generates 3 alphas per batch
- Ollama Integration: Uses local LLM for alpha idea generation
- WorldQuant Testing: Tests each alpha immediately
2. Alpha Mining
- Expression Mining: Analyzes promising alphas for variations
- Pattern Recognition: Identifies successful alpha patterns
- Optimization: Suggests improvements to existing alphas
3. Alpha Submission
- Daily Limit: Submits only once per day
- Success Filtering: Only submits alphas with good performance
- Rate Limiting: Respects WorldQuant API limits
Performance Improvements
Generation Speed
- Before: ~10-15 seconds per alpha (Kimi API)
- After: ~3-5 seconds per alpha (Local Ollama + GPU)
Automation
- Before: Manual intervention required
- After: Fully automated 24/7 operation
File Structure
…
️ Technical Stack
Backend
- Python 3.8: Main application language
- Flask: Web dashboard framework
- Requests: HTTP client for APIs
- Schedule: Task scheduling
- PyTorch: GPU acceleration support
Infrastructure
- Docker: Containerization
- Docker Compose: Multi-service orchestration
- NVIDIA CUDA: GPU acceleration
- Ollama: Local LLM serving
Frontend
- HTML5/CSS3: Dashboard interface
- JavaScript: Real-time updates
- Responsive Design: Mobile-friendly layout
Security
- Local Processing: All LLM inference happens locally
- Credential Protection: Credentials stored in mounted volume
- Network Isolation: Docker network isolation
- API Rate Limiting: Respects external API limits
Documentation
For detailed documentation, see:
Why Choose Naive-Ollama?
- Performance: 3-5x faster than Kimi API
- Cost: No external API costs
- Privacy: All processing happens locally
- Control: Full control over the LLM and workflow
- Automation: 24/7 continuous operation
- Monitoring: Real-time web dashboard
- Scalability: GPU acceleration support
- Reliability: Docker containerization
Pre-Consultant
This is basically a closed loop system where it starts with alpha_generator.py, which generates alpha ideas with Kimi AI. Then it dumps promising alpha to a local log file, which promising_alpha_miner.py will mine for better results, and dumps refined alpha to a local log file, which you can run successful_alpha_submitter.py to submit to the WorldQuant platform. These script can run concurrently.
While alpha_expression_miner.py is more of a utility script to mine alpha expressions from a given expression manually but not within the aforementioned closed loop system.
alpha_101_testing is currently under development.
alpha_polisher.py is currently under development.
Installation
pip install -r requirements.txt
Usage
Alpha Generator
The pre-consultant Python alpha generator uses Kimi AI to generate alpha expressions. Notice this may get you some alpha ideas as long as you are fine with the cost.
Human in the loop control is the future development direction of this script.
python alpha_generator.py
Alpha Expression Miner
This script is used to mine alpha expressions from a given expression.
…
Clean Up Logs
This script is used to clean up the logs.
python clean_up_logs.py
Successful Alpha Submitter
This script is used to submit successful alphas to the WorldQuant platform. It's not recommended to use this script as of now because it submits alphas in one batch instead of once per day.
python successful_alpha_submitter.py
Pre-Consultant Non-AI
The machine_lib.py module provides core functionality for alpha generation and testing through the WorldQuant platform. Here are the key components:
WorldQuantBrain Class
The main class that handles interactions with WorldQuant's API and alpha generation logic:
- Authentication and session management with WorldQuant platform
- Fetching and processing data fields (matrix and vector types)
- Generating alpha expressions using operators and data fields
- Running simulations to test alpha performance
- Processing and analyzing simulation results
Key Features
- Automated alpha generation using combinations of:
- Data fields (matrix and vector types)
- Mathematical operators (+, -, *, /, etc.)
- Ranking and scoring functions
- Time series operations
- Simulation capabilities:
- Single alpha testing
- Batch simulation support
- Performance metrics calculation
- Result processing:
- Filtering based on performance thresholds
- Storing successful alphas
- Error handling and logging
Data Processing
- Data field categorization (matrix vs vector)
- Expression validation
- Performance metric calculations:
- Information Ratio (IR)
- Returns
- Turnover
- Correlation analysis
The library serves as the foundation for automated alpha mining and testing, providing the necessary tools to interact with WorldQuant's platform programmatically.
python machine_miner.py --username your_worldquant_username --password your_worldquant_password
Consultant
Just like the pre-consultant non ai but without workaround like single simulation and skip for inaccessible data fields and operators.
Installation
pip install -r requirements.txt
Usage
python machine_miner.py --username your_worldquant_username --password your_worldquant_password
Project Evolution
Latest: Naive-Ollama (v2.0)
- Local LLM Integration: Ollama with llama3.2:3b/llama2:7b models
- GPU Acceleration: NVIDIA CUDA support for faster inference
- Web Dashboard: Real-time monitoring and control interface
- Automated Orchestration: Continuous alpha generation, mining, and submission
- Docker Support: Easy deployment with containerization
- Performance: 3-5x faster